add 'pandora_client install_programs update'

This commit is contained in:
j 2014-03-02 15:12:34 +01:00
parent b950c187f4
commit 506df5939f
2 changed files with 10 additions and 7 deletions

View file

@ -37,7 +37,7 @@ if __name__ == '__main__':
parser.print_help() parser.print_help()
sys.exit(1) sys.exit(1)
actions = ('scan', 'sync', 'upload', 'upload_frames', 'extract', 'clean', 'cmd', 'import_srt', 'upload_document') actions = ('scan', 'sync', 'upload', 'upload_frames', 'extract', 'clean', 'cmd', 'import_srt', 'upload_document', 'install_programs')
config = ('config', 'add_volume') config = ('config', 'add_volume')
server = ('server', 'client') server = ('server', 'client')
if not args or args[0] not in actions + config + server: if not args or args[0] not in actions + config + server:

View file

@ -421,23 +421,26 @@ class Client(object):
self._config['url'] = url self._config['url'] = url
self.save_config() self.save_config()
print "\nconfiguration updated." print "\nconfiguration updated."
self.install_programs()
def install_programs(self, args=[]):
update = 'update' in args
#install required programs #install required programs
if sys.platform == 'darwin': if sys.platform == 'darwin':
osname = 'macosx' osext = 'macosx'
elif sys.platform == 'win32': elif sys.platform == 'win32':
osname = 'exe' osext = 'exe'
else: else:
osname = 'linux' osext = 'linux'
bindir = os.path.expanduser('~/.ox/bin') bindir = os.path.expanduser('~/.ox/bin')
ox.makedirs(bindir) ox.makedirs(bindir)
for p in ('ffmpeg', 'ffmpeg2theora'): for p in ('ffmpeg', 'ffmpeg2theora'):
path = os.path.join(bindir, p) path = os.path.join(bindir, p)
if sys.platform == 'win32': if sys.platform == 'win32':
p += '.exe' p += '.exe'
if not os.path.exists(path): if not os.path.exists(path) or update:
print "installing %s in %s" % (p, bindir) print "installing %s in %s" % (p, bindir)
ox.net.save_url('http://firefogg.org/bin/%s.%s' % (p, osname), path) ox.net.save_url('http://firefogg.org/bin/%s.%s' % (p, osext), path, True)
os.chmod(path, 0755) os.chmod(path, 0755)
def add_volume(self, args): def add_volume(self, args):
@ -470,7 +473,7 @@ class Client(object):
return volumes return volumes
def scan(self, args): def scan(self, args):
rescan = '--rescan' in args rescan = 'rescan' in args
print "checking for new files ..." print "checking for new files ..."
volumes = self.active_volumes() volumes = self.active_volumes()
for name in sorted(volumes): for name in sorted(volumes):