~usb-creator-hackers/usb-creator/trunk

« back to all changes in this revision

Viewing changes to bin/usb-creator-gtk

  • Committer: Dmitrijs Ledkovs
  • Date: 2013-01-24 17:00:31 UTC
  • mto: This revision was merged to the branch mainline in revision 407.
  • Revision ID: dmitrijs.ledkovs@canonical.com-20130124170031-0w7zc2kkaj86uu7x
Support flashing devices using fastboot (e.g. Nexus7).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
 
1
#!/usr/bin/python3
2
2
 
3
3
# Copyright (C) 2009 Canonical Ltd.
4
4
 
27
27
    os.environ['USBCREATOR_LOCAL'] = '1'
28
28
from usbcreator.frontends.gtk import GtkFrontend
29
29
from usbcreator.backends.udisks import UDisksBackend
 
30
from usbcreator.backends.fastboot import FastbootBackend
30
31
from usbcreator.misc import sane_path, setup_gettext, setup_logging, text_type
31
32
 
32
33
sane_path()
56
57
                  help=_('allow writing to system-internal devices'))
57
58
parser.add_option('--show-all', dest='show_all', action='store_true',
58
59
                  help=_('Show all devices'))
 
60
parser.add_option('--fastboot', dest='fastboot', action='store_true',
 
61
                  help=_('Use fastboot backend to flash Android devices.'))
59
62
(options, args) = parser.parse_args()
60
63
 
61
64
try:
62
 
    backend = UDisksBackend(allow_system_internal=options.allow_system_internal,
63
 
                            show_all=options.show_all)
64
 
    frontend = GtkFrontend(backend, options.img, options.persistent,
65
 
                           allow_system_internal=options.allow_system_internal)
 
65
    if options.fastboot:
 
66
        options.persistent = False
 
67
        backend = FastbootBackend()
 
68
    else:
 
69
        backend = UDisksBackend(
 
70
            allow_system_internal=options.allow_system_internal,
 
71
            show_all=options.show_all)
 
72
    frontend = GtkFrontend(
 
73
        backend, options.img, options.persistent,
 
74
        allow_system_internal=options.allow_system_internal,
 
75
        fastboot_mode=options.fastboot,
 
76
        )
66
77
except DBusException as e:
67
78
    # FIXME evand 2009-07-09: Wouldn't service activation pick this up
68
79
    # automatically?