Example #1
0
def main():
 """Command line main"""
 parser = argparse.ArgumentParser()
 subparsers = parser.add_subparsers(dest='command', title='commands')
 install = subparsers.add_parser('install', description='Installs an apk file on the camera connected via USB. The connection can be tested without specifying a file.')
 install.add_argument('-s', dest='server', help='hostname for the remote server (set to empty to start a local server)', default='sony-pmca.appspot.com')
 install.add_argument('-d', dest='driver', choices=['libusb', 'windows'], help='specify the driver')
 install.add_argument('-o', dest='outFile', type=argparse.FileType('w'), help='write the output to this file')
 install.add_argument('-f', dest='apkFile', type=argparse.FileType('rb'), help='the apk file to install')
 market = subparsers.add_parser('market', description='Download apps from the official Sony app store')
 market.add_argument('-t', dest='token', help='Specify an auth token')
 market = subparsers.add_parser('apk2spk', description='Convert apk to spk')
 market.add_argument('inFile', metavar='app.apk', type=argparse.FileType('rb'), help='the apk file to convert')
 market.add_argument('outFile', metavar='app' + spk.constants.extension, type=argparse.FileType('wb'), help='the output spk file')
 market = subparsers.add_parser('spk2apk', description='Convert spk to apk')
 market.add_argument('inFile', metavar='app' + spk.constants.extension, type=argparse.FileType('rb'), help='the spk file to convert')
 market.add_argument('outFile', metavar='app.apk', type=argparse.FileType('wb'), help='the output apk file')

 args = parser.parse_args()
 if args.command == 'install':
  installCommand(args.server, args.driver, args.apkFile, args.outFile)
 elif args.command == 'market':
  marketCommand(args.token)
 elif args.command == 'apk2spk':
  args.outFile.write(spk.dump(args.inFile.read()))
 elif args.command == 'spk2apk':
  args.outFile.write(spk.parse(args.inFile.read()))
Example #2
0
def main():
 """Command line main"""
 parser = argparse.ArgumentParser()
 if version:
  parser.add_argument('--version', action='version', version=version)
 subparsers = parser.add_subparsers(dest='command', title='commands')
 info = subparsers.add_parser('info', description='Display information about the camera connected via USB')
 info.add_argument('-d', dest='driver', choices=['libusb', 'native'], help='specify the driver')
 install = subparsers.add_parser('install', description='Installs an apk file on the camera connected via USB. The connection can be tested without specifying a file.')
 install.add_argument('-s', dest='server', help='hostname for the remote server (set to empty to start a local server)', default=config.appengineServer)
 install.add_argument('-d', dest='driver', choices=['libusb', 'native'], help='specify the driver')
 install.add_argument('-o', dest='outFile', type=argparse.FileType('w'), help='write the output to this file')
 installMode = install.add_mutually_exclusive_group()
 installMode.add_argument('-f', dest='apkFile', type=argparse.FileType('rb'), help='install an apk file')
 installMode.add_argument('-a', dest='appPackage', help='the package name of an app from the app list')
 installMode.add_argument('-i', dest='appInteractive', action='store_true', help='select an app from the app list (interactive)')
 market = subparsers.add_parser('market', description='Download apps from the official Sony app store')
 market.add_argument('-t', dest='token', help='Specify an auth token')
 apk2spk = subparsers.add_parser('apk2spk', description='Convert apk to spk')
 apk2spk.add_argument('inFile', metavar='app.apk', type=argparse.FileType('rb'), help='the apk file to convert')
 apk2spk.add_argument('outFile', metavar='app' + spk.constants.extension, type=argparse.FileType('wb'), help='the output spk file')
 spk2apk = subparsers.add_parser('spk2apk', description='Convert spk to apk')
 spk2apk.add_argument('inFile', metavar='app' + spk.constants.extension, type=argparse.FileType('rb'), help='the spk file to convert')
 spk2apk.add_argument('outFile', metavar='app.apk', type=argparse.FileType('wb'), help='the output apk file')
 firmware = subparsers.add_parser('firmware', description='Update the firmware')
 firmware.add_argument('-f', dest='datFile', type=argparse.FileType('rb'), required=True, help='the firmware file')
 firmware.add_argument('-d', dest='driver', choices=['libusb', 'native'], help='specify the driver')

 args = parser.parse_args()
 if args.command == 'info':
  infoCommand(config.appengineServer, args.driver)
 elif args.command == 'install':
  if args.appInteractive:
   pkg = appSelectionCommand(args.server)
   if not pkg:
    return
  else:
   pkg = args.appPackage
  installCommand(args.server, args.driver, args.apkFile, pkg, args.outFile)
 elif args.command == 'market':
  marketCommand(args.token)
 elif args.command == 'apk2spk':
  args.outFile.write(spk.dump(args.inFile.read()))
 elif args.command == 'spk2apk':
  args.outFile.write(spk.parse(args.inFile.read()))
 elif args.command == 'firmware':
  firmwareUpdateCommand(args.datFile, args.driver)
 else:
  parser.print_usage()
Example #3
0
def marketCommand(token=None):
    if not token:
        print 'Please enter your Sony Entertainment Network credentials\n'
        email = raw_input('Email: ')
        password = getpass('Password: '******'Login successful. Your auth token (use with the -t option):\n%s\n' % token
        else:
            print 'Login failed'
            return

    devices = marketclient.getDevices(token)
    print '%d devices found\n' % len(devices)

    apps = []
    for device in devices:
        print '%s (%s)' % (device.name, device.serial)
        for app in marketclient.getApps(device.deviceid):
            if not app.price:
                apps.append((device.deviceid, app.id))
                print ' [%2d] %s' % (len(apps), app.name)
        print ''

    if apps:
        while True:
            i = int(raw_input('Enter number of app to download (0 to exit): '))
            if i == 0:
                break
            app = apps[i - 1]
            print 'Downloading app %s' % app[1]
            spkName, spkData = marketclient.download(token, app[0], app[1])
            fn = re.sub('(%s)?$' % re.escape(spk.constants.extension), '.apk',
                        spkName)
            data = spk.parse(spkData)

            if os.path.exists(fn):
                print 'File %s exists already' % fn
            else:
                with open(fn, 'wb') as f:
                    f.write(data)
                print 'App written to %s' % fn
            print ''
Example #4
0
def marketCommand(token=None):
 if not token:
  print 'Please enter your Sony Entertainment Network credentials\n'
  email = raw_input('Email: ')
  password = getpass('Password: '******'Login successful. Your auth token (use with the -t option):\n%s\n' % token
  else:
   print 'Login failed'
   return

 devices = marketclient.getDevices(token)
 print '%d devices found\n' % len(devices)

 apps = []
 for device in devices:
  print '%s (%s)' % (device.name, device.serial)
  for app in marketclient.getApps(device.deviceid):
   if not app.price:
    apps.append((device.deviceid, app.id))
    print ' [%2d] %s' % (len(apps), app.name)
  print ''

 if apps:
  while True:
   i = int(raw_input('Enter number of app to download (0 to exit): '))
   if i == 0:
    break
   app = apps[i - 1]
   print 'Downloading app %s' % app[1]
   spkName, spkData = marketclient.download(token, app[0], app[1])
   fn = re.sub('(%s)?$' % re.escape(spk.constants.extension), '.apk', spkName)
   data = spk.parse(spkData)

   if os.path.exists(fn):
    print 'File %s exists already' % fn
   else:
    with open(fn, 'wb') as f:
     f.write(data)
    print 'App written to %s' % fn
   print ''
Example #5
0
def main():
    """Command line main"""
    parser = argparse.ArgumentParser()
    if version:
        parser.add_argument('--version', action='version', version=version)
    subparsers = parser.add_subparsers(dest='command', title='commands')
    info = subparsers.add_parser(
        'info',
        description='Display information about the camera connected via USB')
    info.add_argument('-d',
                      dest='driver',
                      choices=['libusb', 'native'],
                      help='specify the driver')
    install = subparsers.add_parser(
        'install',
        description=
        'Installs an apk file on the camera connected via USB. The connection can be tested without specifying a file.'
    )
    install.add_argument('-d',
                         dest='driver',
                         choices=['libusb', 'native'],
                         help='specify the driver')
    install.add_argument('-o',
                         dest='outFile',
                         type=argparse.FileType('w'),
                         help='write the output to this file')
    install.add_argument('-l',
                         dest='local',
                         action='store_true',
                         help='local only (don\'t send statistics)')
    installMode = install.add_mutually_exclusive_group()
    installMode.add_argument('-f',
                             dest='apkFile',
                             type=argparse.FileType('rb'),
                             help='install an apk file')
    installMode.add_argument(
        '-a',
        dest='appPackage',
        help='the package name of an app from the app list')
    installMode.add_argument(
        '-i',
        dest='appInteractive',
        action='store_true',
        help='select an app from the app list (interactive)')
    market = subparsers.add_parser(
        'market', description='Download apps from the official Sony app store')
    market.add_argument('-t', dest='token', help='Specify an auth token')
    apk2spk = subparsers.add_parser('apk2spk',
                                    description='Convert apk to spk')
    apk2spk.add_argument('inFile',
                         metavar='app.apk',
                         type=argparse.FileType('rb'),
                         help='the apk file to convert')
    apk2spk.add_argument('outFile',
                         metavar='app' + spk.constants.extension,
                         type=argparse.FileType('wb'),
                         help='the output spk file')
    spk2apk = subparsers.add_parser('spk2apk',
                                    description='Convert spk to apk')
    spk2apk.add_argument('inFile',
                         metavar='app' + spk.constants.extension,
                         type=argparse.FileType('rb'),
                         help='the spk file to convert')
    spk2apk.add_argument('outFile',
                         metavar='app.apk',
                         type=argparse.FileType('wb'),
                         help='the output apk file')
    firmware = subparsers.add_parser('firmware',
                                     description='Update the firmware')
    firmware.add_argument('-f',
                          dest='datFile',
                          type=argparse.FileType('rb'),
                          required=True,
                          help='the firmware file')
    firmware.add_argument('-d',
                          dest='driver',
                          choices=['libusb', 'native'],
                          help='specify the driver')
    updaterShell = subparsers.add_parser(
        'updatershell', description='Launch firmware updater debug shell')
    updaterShell.add_argument('-d',
                              dest='driver',
                              choices=['libusb', 'native'],
                              help='specify the driver')
    updaterShellMode = updaterShell.add_mutually_exclusive_group()
    updaterShellMode.add_argument('-f',
                                  dest='fdatFile',
                                  type=argparse.FileType('rb'),
                                  help='firmware file')
    updaterShellMode.add_argument('-m', dest='model', help='model name')
    gps = subparsers.add_parser('gps', description='Update GPS assist data')
    gps.add_argument('-d',
                     dest='driver',
                     choices=['libusb', 'native'],
                     help='specify the driver')
    gps.add_argument('-f',
                     dest='file',
                     type=argparse.FileType('rb'),
                     help='assistme.dat file')
    stream = subparsers.add_parser(
        'stream', description='Update Streaming configuration')
    stream.add_argument('-d',
                        dest='driver',
                        choices=['libusb', 'native'],
                        help='specify the driver')
    stream.add_argument('-f',
                        dest='file',
                        type=argparse.FileType('w'),
                        help='store current settings to file')
    stream.add_argument('-w',
                        dest='write',
                        type=argparse.FileType('r'),
                        help='program camera settings from file')
    wifi = subparsers.add_parser('wifi',
                                 description='Update WiFi configuration')
    wifi.add_argument('-d',
                      dest='driver',
                      choices=['libusb', 'native'],
                      help='specify the driver')
    wifi.add_argument('-m',
                      dest='multi',
                      action='store_true',
                      help='Read/Write "Multi-WiFi" settings')
    wifi.add_argument('-f',
                      dest='file',
                      type=argparse.FileType('w'),
                      help='store current settings to file')
    wifi.add_argument('-w',
                      dest='write',
                      type=argparse.FileType('r'),
                      help='program camera settings from file')

    args = parser.parse_args()
    if args.command == 'info':
        infoCommand(args.driver)
    elif args.command == 'install':
        if args.appInteractive:
            pkg = appSelectionCommand()
            if not pkg:
                return
        else:
            pkg = args.appPackage
        installCommand(args.driver, args.apkFile, pkg, args.outFile,
                       args.local)
    elif args.command == 'market':
        marketCommand(args.token)
    elif args.command == 'apk2spk':
        args.outFile.write(spk.dump(args.inFile.read()))
    elif args.command == 'spk2apk':
        args.outFile.write(spk.parse(args.inFile.read()))
    elif args.command == 'firmware':
        firmwareUpdateCommand(args.datFile, args.driver)
    elif args.command == 'updatershell':
        updaterShellCommand(args.model, args.fdatFile, args.driver)
    elif args.command == 'gps':
        gpsUpdateCommand(args.file, args.driver)
    elif args.command == 'stream':
        streamingCommand(args.write, args.file, args.driver)
    elif args.command == 'wifi':
        wifiCommand(args.write, args.file, args.multi, args.driver)
    else:
        parser.print_usage()
Example #6
0
 def get(self, portalid, deviceid, appid):
  spkName, spkData = marketclient.download(portalid, deviceid, appid)
  apkData = spk.parse(spkData)
  self.output(apkMimeType, apkData, replaceSuffix(spk.constants.extension, apkExtension, spkName))
Example #7
0
 def get(self, portalid, deviceid, appid):
     spkName, spkData = marketclient.download(portalid, deviceid, appid)
     apkData = spk.parse(spkData)
     self.output(
         apkMimeType, apkData,
         replaceSuffix(spk.constants.extension, apkExtension, spkName))
Example #8
0
 def get(self, portalid, deviceid, appid):
  spkName, spkData = marketclient.download(portalid, deviceid, appid)
  apkData = spk.parse(spkData)
  apkName = re.sub('(%s)?$' % re.escape(spk.constants.extension), '.apk', spkName)
  self.output('application/vnd.android.package-archive', apkData, apkName)
Example #9
0
def main():
 """Command line main"""
 parser = argparse.ArgumentParser()
 if version:
  parser.add_argument('--version', action='version', version=version)
 drivers = ['native', 'libusb', 'qemu']
 subparsers = parser.add_subparsers(dest='command', title='commands')
 info = subparsers.add_parser('info', description='Display information about the camera connected via USB')
 info.add_argument('-d', dest='driver', choices=drivers, help='specify the driver')
 install = subparsers.add_parser('install', description='Installs an apk file on the camera connected via USB. The connection can be tested without specifying a file.')
 install.add_argument('-d', dest='driver', choices=drivers, help='specify the driver')
 install.add_argument('-o', dest='outFile', type=argparse.FileType('w'), help='write the output to this file')
 install.add_argument('-l', dest='local', action='store_true', help='local only (don\'t send statistics)')
 installMode = install.add_mutually_exclusive_group()
 installMode.add_argument('-f', dest='apkFile', type=argparse.FileType('rb'), help='install an apk file')
 installMode.add_argument('-a', dest='appPackage', help='the package name of an app from the app list')
 installMode.add_argument('-i', dest='appInteractive', action='store_true', help='select an app from the app list (interactive)')
 market = subparsers.add_parser('market', description='Download apps from the official Sony app store')
 market.add_argument('-t', dest='token', help='Specify an auth token')
 apk2spk = subparsers.add_parser('apk2spk', description='Convert apk to spk')
 apk2spk.add_argument('inFile', metavar='app.apk', type=argparse.FileType('rb'), help='the apk file to convert')
 apk2spk.add_argument('outFile', metavar='app' + spk.constants.extension, type=argparse.FileType('wb'), help='the output spk file')
 spk2apk = subparsers.add_parser('spk2apk', description='Convert spk to apk')
 spk2apk.add_argument('inFile', metavar='app' + spk.constants.extension, type=argparse.FileType('rb'), help='the spk file to convert')
 spk2apk.add_argument('outFile', metavar='app.apk', type=argparse.FileType('wb'), help='the output apk file')
 firmware = subparsers.add_parser('firmware', description='Update the firmware')
 firmware.add_argument('-f', dest='datFile', type=argparse.FileType('rb'), required=True, help='the firmware file')
 firmware.add_argument('-d', dest='driver', choices=drivers, help='specify the driver')
 updaterShell = subparsers.add_parser('updatershell', description='Launch firmware updater debug shell')
 updaterShell.add_argument('-d', dest='driver', choices=drivers, help='specify the driver')
 updaterShellMode = updaterShell.add_mutually_exclusive_group()
 updaterShellMode.add_argument('-f', dest='fdatFile', type=argparse.FileType('rb'), help='firmware file')
 updaterShellMode.add_argument('-m', dest='model', help='model name')
 guessFirmware = subparsers.add_parser('guess_firmware', description='Guess the applicable firmware file')
 guessFirmware.add_argument('-d', dest='driver', choices=drivers, help='specify the driver')
 guessFirmware.add_argument('-f', dest='file', type=argparse.FileType('rb'), required=True, help='input file')
 gps = subparsers.add_parser('gps', description='Update GPS assist data')
 gps.add_argument('-d', dest='driver', choices=drivers, help='specify the driver')
 gps.add_argument('-f', dest='file', type=argparse.FileType('rb'), help='assistme.dat file')
 stream = subparsers.add_parser('stream', description='Update Streaming configuration')
 stream.add_argument('-d', dest='driver', choices=drivers, help='specify the driver')
 stream.add_argument('-f', dest='file', type=argparse.FileType('w'), help='store current settings to file')
 stream.add_argument('-w', dest='write', type=argparse.FileType('r'), help='program camera settings from file')
 wifi = subparsers.add_parser('wifi', description='Update WiFi configuration')
 wifi.add_argument('-d', dest='driver', choices=drivers, help='specify the driver')
 wifi.add_argument('-m', dest='multi', action='store_true', help='Read/Write "Multi-WiFi" settings')
 wifi.add_argument('-f', dest='file', type=argparse.FileType('w'), help='store current settings to file')
 wifi.add_argument('-w', dest='write', type=argparse.FileType('r'), help='program camera settings from file')

 args = parser.parse_args()
 if args.command == 'info':
  infoCommand(args.driver)
 elif args.command == 'install':
  if args.appInteractive:
   pkg = appSelectionCommand()
   if not pkg:
    return
  else:
   pkg = args.appPackage
  installCommand(args.driver, args.apkFile, pkg, args.outFile, args.local)
 elif args.command == 'market':
  marketCommand(args.token)
 elif args.command == 'apk2spk':
  args.outFile.write(spk.dump(args.inFile.read()))
 elif args.command == 'spk2apk':
  args.outFile.write(spk.parse(args.inFile.read()))
 elif args.command == 'firmware':
  firmwareUpdateCommand(args.datFile, args.driver)
 elif args.command == 'updatershell':
  updaterShellCommand(args.model, args.fdatFile, args.driver)
 elif args.command == 'guess_firmware':
  guessFirmwareCommand(args.file, args.driver)
 elif args.command == 'gps':
  gpsUpdateCommand(args.file, args.driver)
 elif args.command == 'stream':
  streamingCommand(args.write, args.file, args.driver)
 elif args.command == 'wifi':
  wifiCommand(args.write, args.file, args.multi, args.driver)
 else:
  parser.print_usage()