/usr/bin/nxt_push is in python-nxt 2.2.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #!/usr/bin/python
#
# nxt_push program -- Push a file to a LEGO Mindstorms NXT brick
# Copyright (C) 2006 Douglas P Lau
# Copyright (C) 2010 rhn
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
import sys
import nxt.locator
from nxt.brick import FileWriter
from nxt.error import FileNotFound
from nxt.utils import parse_command_line_arguments
def _write_file(b, fname, data):
w = FileWriter(b, fname, len(data))
print 'Pushing %s (%d bytes) ...' % (fname, w.size),
sys.stdout.flush()
w.write(data)
print 'wrote %d bytes' % len(data)
w.close()
def write_file(b, fname):
f = open(fname)
data = f.read()
f.close()
try:
b.delete(fname)
print 'Overwriting %s on NXT' % fname
except FileNotFound:
pass
_write_file(b, fname, data)
if __name__ == '__main__':
arguments, keyword_arguments = parse_command_line_arguments(sys.argv)
if '--help' in arguments:
print '''nxt_push -- Push a file to a LEGO Mindstorms NXT brick
Usage: nxt_push [--host <macaddress>] <file>'''
exit(0)
brick = nxt.locator.find_one_brick(keyword_arguments.get('host',None))
for filename in arguments:
write_file(brick, filename)
brick.sock.close()
|