Exemple #1
0
             files.append((self._tabs[self._tab], f.filename))
         for x in files:
             archives = ['.tar.gz', '.tgz', '.gz', '.tar.bz2', '.tbz2', '.bz2', '.zip']
             if self.app.auth.user != 'anonymous':
                 uid, gid = pwd.getpwnam(self.app.auth.user).pw_uid, pwd.getpwnam(self.app.auth.user).pw_gid
                 os.chown(os.path.join(x[0], x[1]), uid, gid)
             for y in archives:
                 if x[1].endswith(y):
                     self._archupl.append((x[0], x[1], y))
                     break
     self._upload = None
 if params[0] == 'dlgArchUpl':
     f = self._archupl[0]
     if vars.getvalue('action', '') == 'OK':
         try:
             utils.extract(os.path.join(f[0], f[1]), f[0], False)
         except Exception, e:
             self.put_message('err', 'Failed to extract %s: %s' % (f[1], str(e)))
     self._archupl.remove(f)
 if params[0] == 'dlgNewFile':
     if vars.getvalue('action', '') == 'OK' and vars.getvalue('value', ''):
         filename = vars.getvalue('value', '')
         if filename[0] != '/':
             filename = os.path.join(self._newfile, filename)
         if os.path.exists(filename):
             self.put_message('err', 'That file already exists!')
         else:
             try:
                 open(filename, 'w')
                 self.put_message('success', 'File created: %s' % filename)
             except Exception, e:
Exemple #2
0
 def on_submit(self, event, params, vars=None):
     if params[0] == 'files':
         act = vars.getvalue('action', '')
         tab = self._tab
         lst = []
         for x in vars:
             if '/' in x and vars.getvalue(x, None) == '1':
                 tab, f = x.split('/')
                 f = self.dec_file(f)
                 lst.append(f)
         if len(lst) > 0:
             if act == 'copy':
                 self._clipboard = lst
                 self._cbs = 'copy'
             if act == 'cut':
                 self._clipboard = lst
                 self._cbs = 'cut'
             if act == 'rename':
                 self._renaming = lst[0]
         self._tab = tab
     if params[0] == 'dlgRename':
         if vars.getvalue('action', None) == 'OK':
             os.rename(self._renaming,
                 os.path.join(
                     os.path.split(self._renaming)[0],
                     vars.getvalue('value', None)
                 ))
         self._renaming = None
     if params[0] == 'dlgAcl':
         self._editing_acl = None
     if params[0] == 'dlgUpload':
         if vars.getvalue('action', '') == 'OK' and vars.has_key('file'):
             files = []
             if type(vars['file']) == list:
                 names = []
                 for x in vars['file']:
                     open(os.path.join(self._tabs[self._tab], x.filename), 'w').write(x.value)
                     names.append(x.filename)
                     files.append((self._tabs[self._tab], x.filename))
                 self.put_message('info', 'Uploaded the following files to %s: %s'
                     % (self._tabs[self._tab], ', '.join(names)))
             else:
                 f = vars['file']
                 open(os.path.join(self._tabs[self._tab], f.filename), 'w').write(f.value)
                 self.put_message('info', 'Uploaded %s to %s'
                     % (f.filename, self._tabs[self._tab]))
                 files.append((self._tabs[self._tab], f.filename))
             for x in files:
                 archives = ['.tar.gz', '.tgz', '.gz', '.tar.bz2', '.tbz2', '.bz2', '.zip']
                 for y in archives:
                     if x[1].endswith(y):
                         self._archupl.append((x[0], x[1], y))
                         break
         self._upload = None
     if params[0] == 'dlgArchUpl':
         f = self._archupl[0]
         if vars.getvalue('action', '') == 'OK':
             try:
                 utils.extract(os.path.join(f[0], f[1]), f[0], False)
             except Exception, e:
                 self.put_message('err', 'Failed to extract %s: %s' % (f[1], str(e)))
         self._archupl.remove(f)
Exemple #3
0
 def on_submit(self, event, params, vars=None):
     if params[0] == 'files':
         act = vars.getvalue('action', '')
         tab = self._tab
         lst = []
         for x in vars:
             if '/' in x and vars.getvalue(x, None) == '1':
                 tab, f = x.split('/')
                 f = self.dec_file(f)
                 lst.append(f)
         if len(lst) > 0:
             if act == 'copy':
                 self._clipboard = lst
                 self._cbs = 'copy'
             if act == 'cut':
                 self._clipboard = lst
                 self._cbs = 'cut'
             if act == 'rename':
                 self._renaming = lst[0]
         self._tab = tab
     if params[0] == 'dlgRename':
         if vars.getvalue('action', None) == 'OK':
             os.rename(
                 self._renaming,
                 os.path.join(
                     os.path.split(self._renaming)[0],
                     vars.getvalue('value', None)))
         self._renaming = None
     if params[0] == 'dlgAcl':
         self._editing_acl = None
     if params[0] == 'dlgUpload':
         if vars.getvalue('action', '') == 'OK' and vars.has_key('file'):
             files = []
             if type(vars['file']) == list:
                 names = []
                 for x in vars['file']:
                     open(os.path.join(self._tabs[self._tab], x.filename),
                          'w').write(x.value)
                     names.append(x.filename)
                     files.append((self._tabs[self._tab], x.filename))
                 self.put_message(
                     'info', 'Uploaded the following files to %s: %s' %
                     (self._tabs[self._tab], ', '.join(names)))
             else:
                 f = vars['file']
                 open(os.path.join(self._tabs[self._tab], f.filename),
                      'w').write(f.value)
                 self.put_message(
                     'info', 'Uploaded %s to %s' %
                     (f.filename, self._tabs[self._tab]))
                 files.append((self._tabs[self._tab], f.filename))
             for x in files:
                 archives = [
                     '.tar.gz', '.tgz', '.gz', '.tar.bz2', '.tbz2', '.bz2',
                     '.zip'
                 ]
                 for y in archives:
                     if x[1].endswith(y):
                         self._archupl.append((x[0], x[1], y))
                         break
         self._upload = None
     if params[0] == 'dlgArchUpl':
         f = self._archupl[0]
         if vars.getvalue('action', '') == 'OK':
             try:
                 utils.extract(os.path.join(f[0], f[1]), f[0], False)
             except Exception, e:
                 self.put_message(
                     'err', 'Failed to extract %s: %s' % (f[1], str(e)))
         self._archupl.remove(f)