コード例 #1
0
ファイル: main.py プロジェクト: we-host/file-villin
def ftp_upload(file_path):
    host = ''
    user = '' 
    password = ''
   
    f = ftpretty(host, user, password )
    f.put(file_path , '/')
コード例 #2
0
ファイル: core.py プロジェクト: thylong/cabu
    def __init__(self, import_name=__package__, db=None, *args, **kwargs):
        """Cabu main class, acts as a WSGI interface.

        It overrides Flask to include the config, the Selenium WebDriver,
        the Database, eventually an S3 bucket and a FTP.

        Args:
            import_name (str): Same as for Flask initialization.
            db (Optional[object]): The database driver class. Defaults to None.

        Returns:
            object: A Flask instance plus Cabu specific attributes.
        """
        super(Cabu, self).__init__(import_name, **kwargs)
        settings_path = os.environ.get('CABU_SETTINGS', 'cabu.default_settings')
        self.load_config(settings_path)

        if db:
            if 'DATABASE_URI' not in self.config:
                if db.__name__ == 'PyMongo':
                    default_uri = 'mongodb://localhost/%s' % self.name
                else:
                    raise ConfigurationException(
                        'Unknown database missing DATABASE_URI setting.'
                    )

                self.config['DATABASE_URI'] = os.environ.get(
                    'DATABASE_URI', default_uri
                )
            mongo = db(self, config_prefix='DATABASE')
            with self.app_context():
                self.db = mongo.db
                self.cookies = CookieStorage(self.db)

        if self.config.get('S3_BUCKET'):
            self.bucket = Bucket(
                self.config['S3_BUCKET'],
                self.config['S3_ACCESS_KEY'],
                self.config['S3_SECRET_KEY']
            )

        if self.config.get('FTP_HOST'):  # pragma: no cover
            self.ftp = ftpretty(
                self.config['FTP_HOST'],
                self.config['FTP_LOGIN'],
                self.config['FTP_PASSWORD']
            )

        self.vdisplay = load_vdisplay(self.config)
        self.webdriver = load_driver(self.config, self.vdisplay)
コード例 #3
0
ファイル: my_ftp.py プロジェクト: miquel-corral/crpt201511
 def get_binary_file(self, remote_folder, remote_file_name):
     contents = None
     try:
         # open connection
         f = ftpretty(FTP_HOST, FTP_USER, FTP_PASS)
         # cd base folder
         f.cd(FTP_BASE_DIR)
         # download the file
         contents = f.get(remote_folder + "/" + remote_file_name)
     except:
         print("Unexpected error:", sys.exc_info())
     finally:
         if f:
             f.close()
         return contents
コード例 #4
0
ファイル: my_ftp.py プロジェクト: crppbcn/crpt2015brw
 def get_binary_file(self,remote_folder, remote_file_name):
     contents = None
     try:
         # open connection
         f = ftpretty(FTP_HOST, FTP_USER, FTP_PASS)
         # cd base folder
         f.cd(FTP_BASE_DIR)
         # download the file
         contents = f.get(remote_folder + SLASH + remote_file_name)
     except:
         print("Unexpected error:", sys.exc_info())
     finally:
         if f:
             f.close()
         return contents
コード例 #5
0
ファイル: my_ftp.py プロジェクト: crppbcn/crpt2015brw
 def download_file(self, remote_folder, remote_file_name, local_file_path):
     try:
         # open connection
         f = ftpretty(FTP_HOST, FTP_USER, FTP_PASS)
         # cd base folder
         f.cd(FTP_BASE_DIR)
         # download the file
         contents = f.get(remote_folder + SLASH + remote_file_name)
         my_file = open(local_file_path, 'wb')
         my_file.write(contents)
         my_file.close()
     except:
         print("Unexpected error:", sys.exc_info())
     finally:
         if f:
             f.close()
コード例 #6
0
ファイル: my_ftp.py プロジェクト: miquel-corral/crpt201511
 def download_file(self, remote_folder, remote_file_name, local_file_path):
     try:
         # open connection
         f = ftpretty(FTP_HOST, FTP_USER, FTP_PASS)
         # cd base folder
         f.cd(FTP_BASE_DIR)
         # download the file
         contents = f.get(remote_folder + "/" + remote_file_name)
         my_file = open(local_file_path, 'wb')
         my_file.write(contents)
         my_file.close()
     except:
         print("Unexpected error:", sys.exc_info())
     finally:
         if f:
             f.close()
コード例 #7
0
def place_test_file_in_fpga(file_path, host_addr='192.168.43.3', remote_file_path='/home/root/Vitis-AI/dex_read'):
    """
    File copies the file pointed to by file_path to the remote_file_path on the server pointed to by host_addr
    """

    # Supply the credentisals
    f = ftpretty(host_addr, "root", "root")

    file = np.load(file_path)  # read in the numpy file
    
    # Get a file, save it locally
    # f.get('someremote/file/on/server.txt', '/tmp/localcopy/server.txt')

    # Put a local file to a remote location
    # non-existent subdirectories will be created automatically
    f.put(file_path, remote_file_path+'/')
コード例 #8
0
ファイル: filetransfer.py プロジェクト: ssirimulla/D3R
    def connect(self):
        if self._alt_ftp_con is None:
            try:

                logger.debug('Connecting to ' + str(self.get_host()) +
                             ' with user ' + str(self.get_user()))
                self._ftp = ftpretty(self.get_host(),
                                     self.get_user(),
                                     self.get_password(),
                                     timeout=self.get_connect_timeout())
                return True
            except:
                logger.exception('Unable to connect to ftp host')
                self._error_msg = 'Unable to connect to ftp host'
                return False
        self._ftp = self._alt_ftp_con
        return True
コード例 #9
0
ファイル: my_ftp.py プロジェクト: miquel-corral/crppdmt
    def upload_file(self, local_file_path, remote_folder, remote_file_name):
        try:
            ret = 0
            # open connection
            f = ftpretty(FTP_HOST, FTP_USER, FTP_PASS)
            # cd base folder
            f.cd(FTP_BASE_DIR)
            # put the file

            print("local_file_path: " +  local_file_path)
            print("remote_folder: " + remote_folder)
            print("remote_file_name: " + remote_file_name)

            ret = f.put(local_file_path, remote_folder + "/" + remote_file_name)
        except:
            print("Unexpected error:", sys.exc_info())
        finally:
            if f:
                f.close()
            return ret
コード例 #10
0
ファイル: my_ftp.py プロジェクト: miquel-corral/crpt201511
    def upload_file(self, local_file_path, remote_folder, remote_file_name):
        try:
            ret = 0
            # open connection
            f = ftpretty(FTP_HOST, FTP_USER, FTP_PASS)
            # cd base folder
            f.cd(FTP_BASE_DIR)
            # put the file

            print("local_file_path: " + local_file_path)
            print("remote_folder: " + remote_folder)
            print("remote_file_name: " + remote_file_name)

            ret = f.put(local_file_path,
                        remote_folder + "/" + remote_file_name)
        except:
            print("Unexpected error:", sys.exc_info())
        finally:
            if f:
                f.close()
            return ret
コード例 #11
0
    def perform(self, *args, **kwargs):
        import click

        files_to_copy = kwargs.pop('copied_files')
        if len(files_to_copy) == 0:
            files_to_copy = kwargs.pop('jar_files')

        ftp_client = ftpretty(host=kwargs.pop("host"),
                              user=kwargs.pop("user"),
                              password=kwargs.pop("password"))

        put_directory = kwargs.pop('directory')

        click.echo("Connected to FTP Remote Host; Uploading files to %s" %
                   put_directory)

        ftp_client.cd(put_directory)

        for copied in files_to_copy:
            base_file = os.path.basename(copied)
            ftp_client.put(copied, base_file)
            click.echo("Uploaded %s to %s" % (base_file, put_directory))

        ftp_client.close()
コード例 #12
0
 def test_custom_port(self):
     ftpretty(None, None, None, ftp_conn=self.mock_ftp, port=2121)
コード例 #13
0
 def test_set_pasv(self):
     ftpretty(None, None, None, ftp_conn=self.mock_ftp, passive=False)
コード例 #14
0
 def setUp(self):
     self.mock_ftp = MockFTP()
     self.pretty = ftpretty(None, None, None, ftp_conn=self.mock_ftp)
コード例 #15
0
ファイル: test_ftpretty.py プロジェクト: chriscannon/ftpretty
 def setUp(self):
     self.mock_ftp = MockFTP()
     self.pretty = ftpretty(None, None, None, ftp_conn=self.mock_ftp)
コード例 #16
0
ファイル: test_ftpretty.py プロジェクト: chriscannon/ftpretty
 def test_set_pasv(self):
     pretty = ftpretty(None, None, None, ftp_conn=self.mock_ftp, passive=False)
コード例 #17
0
 def __init__(self, *args, **kwargs):
     self.conn = ftpretty(*args, **kwargs)
コード例 #18
0
ファイル: ftp_crawler.py プロジェクト: wdtgbot/userbot
import os

from ftpretty import ftpretty

from userbot import config

host = config.get('seedbox', 'host', fallback=None)
username = config.get('seedbox', 'username', fallback=None)
password = config.get('seedbox', 'password', fallback=None)
ftp = ftpretty(host=host, user=username, password=password)


async def tree(path):
    files = []
    ftp.cd(path)
    for x in ftp.list(ftp.pwd(), extra=True):
        if x['directory'] == 'd':
            inner_files = await tree(x['name'])
            files = files + inner_files
            ftp.cd('..')
        elif x['directory'] == '-':
            file_name = f"{ftp.pwd()}/{x['name']}"
            files.append([x['datetime'], x['size'], file_name])

    return files


async def get_ftp_files():
    file_list = await tree('downloads/manual')

    files_grouped_by_date = {}
コード例 #19
0
ファイル: my_ftp.py プロジェクト: miquel-corral/crpt201511
 def get_ftp_connection(self):
     return ftpretty(FTP_HOST, FTP_USER, FTP_PASS)
コード例 #20
0
ファイル: gtx.py プロジェクト: timraay/hll_rcon_tool
 def __init__(self, ip, port, username, password) -> None:
     self.conn = ftpretty(ip, username, password, port=port)