Ejemplo n.º 1
0
 def ftp_MD5(self, path):
     line = self.fs.fs2ftp(path)
     try:
         md5_checksum = self.run_as_current_user(self.fs.md5, path)
     except OSError, err:
         why = _strerror(err)
         self.respond('550 %s.' % why)
Ejemplo n.º 2
0
 def ftp_MD5(self, path):
     line = self.fs.fs2ftp(path)
     try:
         md5_checksum = self.run_as_current_user(self.fs.md5, path)
     except OSError, err:
         why = _strerror(err)
         self.respond('550 %s.' % why)
Ejemplo n.º 3
0
 def ftp_SITE_WORDS(self, line):
     try:
         x = os.path.getsize(line)
         self.respond('200 %s' % x)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 ' + why)
Ejemplo n.º 4
0
 def ftp_SITE_WHOAMI(self, line):
     try:
         ret = '%s:%s' % (str(self.__dict__['username']), self.me)
         self.respond('200 %s' % ret)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 %s' % why)
Ejemplo n.º 5
0
 def ftp_SITE_GETTIME(self, line):
     try:
         the_time = self.__get_time()
         self.respond('200 %s' % the_time)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 %s' % why)
Ejemplo n.º 6
0
 def ftp_SITE_SIGNUP(self, line):
     try:
         arg = self.__strip_path_to_list(line)
         if not len(arg) == 1:
             msg = 'Expecting a single arg. Recieved : %s' % str(arg)
             raise AttributeError(msg)
         rep = self.__sign_up(arg[0])
         self.respond('200 %s' % rep)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 ' + why)
Ejemplo n.º 7
0
 def ftp_SITE_IAM(self, line):
     try:
         arg = self.__strip_path_to_list(line)
         if not len(arg) == 1:
             msg = 'Expecting single arg. Recieved: %s' % str(arg)
             raise AttributeError(msg)
         self.me = arg[0]
         self.respond('200 You are now know as: %s:%s' % (str(self.__dict__['username']), arg[0]))
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 %s' % why)
Ejemplo n.º 8
0
 def ftp_SITE_SETFLAG(self, line):
     try:
         args = self.__strip_path_to_list(line)
         if not (len(args) > 0 and len(args) <= 2):
             msg = 'Need 1 or 2 args. Recieved: %s' % str(len(args))
             raise AttributeError(msg)
         else:
             ret = self.__set_flag(args)
             ret = 'a'
             self.respond('200 %s' % ret)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 %s' % why)
Ejemplo n.º 9
0
 def ftp_SITE_GETLOG(self, line):
     """
     Admin Command: Gets the location of the log file. 
     @param line: none. (all ftp_ commands have a param regardless if they use it)
     @return:  The location of the log file on the server. 
     """
     try:
         log = deepcopy(container.get_log_file())
         log = log.split('/')[-1]
         self.respond('200 %s' % log)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 %s' % why)
Ejemplo n.º 10
0
 def ftp_SITE_USERDEL(self, line):  
     """
     Admin Command: Removes a user from the database, 
     and removes their directoy from the file system.
     @param line: represents the username.  see __user_remove.
     """
     try:
         args = self.__strip_path_to_list(line)
         if not len(args) == 1:
             raise AttributeError('Expecting single arg. Not: %s.' % str(args))
         rep = self.__user_remove(args[0])
         self.respond('200 %s' % rep)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 ' + why)
Ejemplo n.º 11
0
 def ftp_SITE_SETPW(self, line):
     """
     User Command: Change their own password.
     @param line: old password.
     @param line: new password. 
     """
     try:
         args = self.__strip_path_to_list(line)
         if not len(args) == 2:
             msg = 'Expecting: old password, new password.' 
             raise AttributeError(msg)
         ret = self.__user_change_password(args[0], args[1])
         self.respond('200 %s' % ret)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 %s' % why)
Ejemplo n.º 12
0
 def ftp_SITE_CHANGEPW(self, line):
     """
     Admin Command: Change user password.
     @param line: username
     @param line: new password
     """
     try:
         args = self.__strip_path_to_list(line)
         if not len(args) == 2:
             msg = 'Expecting: username, new password. Not: %s' % str(args)
             raise AttributeError(msg)
         ret = self.__admin_change_password(args[0], args[1])
         self.respond('200 %s' % ret) 
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 %s' % why)
Ejemplo n.º 13
0
 def ftp_SITE_USERLIST(self, line):
     """  
     Admin Command: Get lists of users.
     @param line: none
     @return: a list of users  
     """ 
     try:
         ret = self.__user_list()
         ret = [str(x) + '\n' for x in ret]
         ret = iter(ret)
         producer = BufferedIteratorProducer(ret)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 ' + why)
     else:
         self.push_dtp_data(producer, isproducer=True, cmd='SITE USERLIST')
         return line
Ejemplo n.º 14
0
 def ftp_SITE_USERADD(self, line):
     """
     Admin command: Add user to database. 
     @param line: Is a single string representing 5 args. see __user_add. 
     """
     try:
         args = self.__strip_path_to_list(line)
         msg = "Expected 3 Args: text, int, txt, txt. Recieved: %s" % ' '.join(args)
         if not len(args) == 3:
             raise AttributeError(msg + ' ' + str(len(args)))
         args[1] = int(args[1])
         if not (args[1] == 0 or args[1] == 1):
             raise AttributeError(msg)
         rep = self.__user_add(args[0], int(args[1]), args[2])
         self.respond('200 %s' % rep)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 ' + why)
Ejemplo n.º 15
0
 def ftp_SITE_SYNC(self, line):
     """
     User Commad: Gets a list of files that needs syncing.
     @param line: represents the user id. (not username)
     @return: a list of files that need to be synced.  
     """
     try:
         time = self.__strip_path_to_list(line)
         if not len(time) == 1:
             raise AttributeError('Expecting a single arg')
         ret = self.__sync(time[0])
         ret = [str(x) + '\n' for x in ret]
         ret = iter(ret)
         producer = BufferedIteratorProducer(ret)
     except:
         err = sys.exc_info()[1]
         why = _strerror(err)
         self.respond('550 ' + why)
     else:
         self.push_dtp_data(producer, isproducer=True, cmd='SITE SYNC')
         return line