コード例 #1
0
ファイル: Control.py プロジェクト: Gonlo2/PyUpManager
    def upload( self, host_name, file_path_to_upload, file_path_remote, accounts_id_list = [],  priority = 5 ):
        self.logger.info( "Adjuntada la subida del fichero '%s' al host '%s'", file_path_to_upload, host_name )

        account_manager = AccountDBManager()

        account_list = []
        if accounts_id_list == []:
            #TODO get all the accounts
            for account in account_manager.get_account_list_of_host( host_name ):
                account_list.append( account )
        else:
            for id in accounts_id_list:
                account_list.append( account_manager.get_account_with_hostname_user( id ) )

        uploader = UploaderFactory().make( host_name + "Uploader", account_list, file_path_to_upload, file_path_remote )

        job = JobFactory().make("UploadJob", uploader, priority = priority )

        db_job = UploadJobDBManager().add( job )
        resultado = self._job_manager.add( db_job )

        if resultado:
            self.logger.info( "Adjuntada con exito la subida '%s' al host '%s'" % ( file_path_to_upload, host_name ) )
            self._uploads_list.append( db_job )
        else:
            self.logger.error( "Error al adjuntar la subida '%s' al host '%s'" % ( file_path_to_upload, host_name ) )

        return resultado
コード例 #2
0
ファイル: Control.py プロジェクト: Gonlo2/PyUpManager
    def delAccount( self, host_name, user ):
        account_manager = AccountDBManager()

        db_account = account_manager.get_account_with_hostname_user( "{}:{}".format( host_name, user ) )
        if db_account == None:
            return False

        db_account.delete()
        return True