more options

This commit is contained in:
j 2011-08-23 21:20:16 +02:00
parent 0de6a5c1c5
commit bfe27b3848
2 changed files with 49 additions and 33 deletions

View file

@ -25,7 +25,7 @@ if __name__ == '__main__':
parser.print_help() parser.print_help()
sys.exit() sys.exit()
actions = ('scan', 'extract', 'sync', 'clean') actions = ('scan', 'sync', 'upload', 'extract', 'clean')
if not args or args[0] not in actions: if not args or args[0] not in actions:
parser.error('you must specify a valid action. \n\t\tknown actions are: %s' % ', '.join(actions)) parser.error('you must specify a valid action. \n\t\tknown actions are: %s' % ', '.join(actions))

View file

@ -264,13 +264,36 @@ class Client(object):
print 'sending info for new files', len(post['info']), offset, total print 'sending info for new files', len(post['info']), offset, total
r = self.api.update(post) r = self.api.update(post)
#send empty list to get updated list of requested info/files/data def upload(self):
post = {'info': {}} if not self.user:
r = self.api.update(post) print "you need to login"
return
conn, c = self._conn()
volumes = {}
for name in self._config['volumes']:
path = self._config['volumes'][name]
path = os.path.normpath(path)
volumes[name] = {}
volumes[name]['path'] = path
if os.path.exists(path):
volumes[name]['available'] = True
else:
volumes[name]['available'] = False
profile = self.api.encodingProfile()['data']['profile']
for name in volumes:
if volumes[name]['available']:
prefix = volumes[name]['path']
files = self.files(prefix)
filenames = {} filenames = {}
for f in files['files']: for f in files['files']:
filenames[f['oshash']] = f['path'] filenames[f['oshash']] = f['path']
#send empty list to get updated list of requested info/files/data
post = {'info': {}}
r = self.api.update(post)
print 'uploading files', len(r['data']['file']) print 'uploading files', len(r['data']['file'])
if r['data']['file']: if r['data']['file']:
@ -292,13 +315,6 @@ class Client(object):
print "failed to login again" print "failed to login again"
return return
else:
pass
#print oshash, "missing"
else:
print "updating volume", name, "failed"
print r
def files(self, prefix): def files(self, prefix):
conn, c = self._conn() conn, c = self._conn()
files = {} files = {}