Exemplo n.º 1
0
Arquivo: grab.py Projeto: metomi/fab
    def run(self, artefact_store: Dict, config):
        super().run(artefact_store, config)

        r = remote.RemoteClient(self.src)
        r.export(str(config.source_root / self.dst_label),
                 revision=self.revision,
                 force=True)
Exemplo n.º 2
0
    def info_function(self, pFunction):
        '''
        Prints the information of a function

        :param dict pFunction: function attributes
        '''
        r = remote.RemoteClient(pFunction['repo_url'] + "/trunk" + pFunction['folder_path'])
        info = r.info()
        print("\n--- %s ---" % pFunction['name'])
        print("Author: %s\nrepo_ur: %s\nDescription: %s\nRuntime: %s\nLast updated on: %s\n" % 
            (pFunction['author'],pFunction['repo_url'],pFunction['description'],pFunction['runtime'], info['commit_date']))
Exemplo n.º 3
0
    def download_function(self, pUrl, pFunctionName):
        '''
        Downloads the folder of a function from a repository

        :param str pUrl: the downloads url direction of the repository
        :param str pFunctionName: the function name
        '''
        r = remote.RemoteClient(pUrl)
        if not os.path.isdir('./'+pFunctionName):
            r.checkout('./'+pFunctionName)
            logger.info("The function %s downloaded succesfully" % pFunctionName)
        else:
            logger.error("The function %s is already configured in your project, please update in order to get last changes" % pFunctionName)
Exemplo n.º 4
0
 def downLoadSvnFile(self, urllink, localpath):
     r = remote.RemoteClient(urllink,
                             username=self.username,
                             password=self.password)
     o = urlparse(r.url)
     base_dir = o.path.split('os')[1].split('/')[1]
     tag_dir = datetime.now().strftime('%Y%m%d_%H%M%S')
     download_dir = os.path.join(localpath, base_dir, tag_dir)
     if not os.path.exists(download_dir):
         os.makedirs(download_dir)
     try:
         r.checkout(download_dir)
     except UnicodeDecodeError as e:
         pass
     return download_dir
Exemplo n.º 5
0
    def svn_msg(self, urllink, path, ipaddr):
        p = path.encode('utf-8')
        result = {}
        for ip in range(len(ipaddr)):
            d = {}
            i = ipaddr[ip]
            i = i.encode('utf-8')
            r = remote.RemoteClient(urllink,
                                    username=self.username,
                                    password=self.password)
            for item in r.list_recursive():
                svnpath = item[0] + '/' + item[1]['name']
                filename = item[1]['name']

                server_path = self.run(i, p, svnpath)

                if not urllink.endswith('/'):
                    urllink = urllink + '/'

                status = 3  #0替换, 1新增, 2未找到,3初始值
                k = item[0] + '/' + item[1]['name']
                svnpath = urllink + k

                if server_path == 'error':
                    status = 2
                elif server_path.split('/')[-1] == svnpath.split('/')[-1]:
                    status = 0
                else:
                    status = 1
                    if not server_path.endswith('/'):
                        server_path = server_path + '/' + filename

                v = {
                    'filename': filename,
                    'author': item[1]['author'],
                    'upload_time':
                    item[1]['date'].strftime('%Y-%m-%d %H:%M:%S'),
                    'svnpath': svnpath,
                    'commit_revision': item[1]['commit_revision'],
                    'commit_size': item[1]['size'],
                    'server_path': server_path,
                    'status': status,
                }
                d[k] = v
                result[i] = d
        return result
Exemplo n.º 6
0
def clone_template(environment, target_dir):
    """
        Observe serverless template and returns the directory path.

            Parameters:
                kind (string): root directory of the repo
                environment (string): sublevel directory of the repo
                target_dir (string): download target

            Returns:
                template_dir (str): path of downloaded template
    """
    try:
        template = ''.join([TEMPLATE_REPO, '/function/', environment])
        print("Getting %s template..." % environment)
        svn_client = remote.RemoteClient(template)
        svn_client.checkout(target_dir)
        print("Successfully fetched template")
        return target_dir
    except Exception:
        print(traceback.format_exc())
Exemplo n.º 7
0
 def remote_repo(self, url):
     return remote.RemoteClient(url, username=self.__username, password=self.__password)