Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: tools/usb_gadget/__main__.py

Issue 412243002: [usb_gadget p09] Software updates over HTTP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/usb_gadget/package.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Package entry-point.""" 5 """Package entry-point."""
6 6
7 import argparse 7 import argparse
8 8
9 import netifaces 9 import netifaces
10 from tornado import ioloop 10 from tornado import ioloop
11 11
12 import linux_gadgetfs 12 import linux_gadgetfs
13 import server 13 import server
14 14
15 15
16 def ParseArgs(): 16 def ParseArgs():
17 """Parse application arguments.""" 17 """Parse application arguments."""
18 parser = argparse.ArgumentParser(description='USB gadget server.') 18 parser = argparse.ArgumentParser(description='USB gadget server.')
19 parser.add_argument( 19 parser.add_argument(
20 '-i', '--interface', default='lo', 20 '-i', '--interface', default='lo',
21 help='Listen for HTTP connections on this interface.') 21 help='Listen for HTTP connections on this interface.')
22 parser.add_argument( 22 parser.add_argument(
23 '-p', '--port', default=8080, 23 '-p', '--port', default=8080,
24 help='Listen for HTTP connections on this port.') 24 help='Listen for HTTP connections on this port.')
25 parser.add_argument( 25 parser.add_argument(
26 '--hardware', default='beaglebone-black', 26 '--hardware', default='beaglebone-black',
27 help='Hardware configuration.') 27 help='Hardware configuration.')
28 parser.add_argument(
29 '--start-claimed',
30 help='Start with the device claimed by this client.')
28 return parser.parse_args() 31 return parser.parse_args()
29 32
30 33
31 def main(): 34 def main():
32 args = ParseArgs() 35 args = ParseArgs()
33 36
34 server.interface = args.interface 37 server.interface = args.interface
35 server.port = args.port 38 server.port = args.port
36 server.hardware = args.hardware 39 server.hardware = args.hardware
40 server.claimed_by = args.start_claimed
37 41
38 addrs = netifaces.ifaddresses(server.interface) 42 addrs = netifaces.ifaddresses(server.interface)
39 ip_address = addrs[netifaces.AF_INET][0]['addr'] 43 ip_address = addrs[netifaces.AF_INET][0]['addr']
40 server.address = '{}:{}'.format(ip_address, server.port) 44 server.address = '{}:{}'.format(ip_address, server.port)
41 45
42 server.chip = linux_gadgetfs.LinuxGadgetfs(server.hardware) 46 server.chip = linux_gadgetfs.LinuxGadgetfs(server.hardware)
43 server.SwitchGadget(server.default) 47 server.SwitchGadget(server.default)
44 48
45 server.http_server.listen(server.port) 49 server.http_server.listen(server.port)
46 50
47 ioloop.IOLoop.instance().start() 51 ioloop.IOLoop.instance().start()
48 print 'Exiting...' 52 print 'Exiting...'
49 53
50 54
51 if __name__ == '__main__': 55 if __name__ == '__main__':
52 main() 56 main()
OLDNEW
« no previous file with comments | « no previous file | tools/usb_gadget/package.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698