示例#1
0
 def before_request():
     '''
     Add id info to `request.data` before request.
     '''
     request.data = {
         "id": utils.md5(request.remote_addr + str(time.time()))
     }
示例#2
0
    def __init__(self, url: str, path: str = None):
        self.url = url
        self.path = os.path.join(SOURCES_HOME, utils.md5(url))

        if self.path.endswith('.git'):
            self.path = self.path[:-4]

        if not os.path.exists(self.path):
            log.logger.info(
                'Git repository {} does not exist, download from remote.'.
                format(self.url))
            self.repo = Repo.clone_from(self.url, self.path)
        else:
            log.logger.info('Git repository {} is located at {}.'.format(
                self.url, self.path))
            self.repo = Repo(self.path)

        self.hub_modules = OrderedDict()
        self.load_hub_modules()
示例#3
0
    def load(cls, directory: str) -> EasyDict:
        '''Load the Module object defined in the specified directory.'''
        module_info = cls.load_module_info(directory)

        # Generate a uuid based on the class information, and dynamically create a new type.
        # If we do not do this, the information generated later will overwrite the information
        # previously generated.
        cls_uuid = utils.md5(module_info.name + module_info.author + module_info.author_email + module_info.type +
                             module_info.summary + module_info.version + directory)
        cls = type('ModuleV1_{}'.format(cls_uuid), (cls, ), {})

        cls.name = module_info.name
        cls.author = module_info.author
        cls.author_email = module_info.author_email
        cls.type = module_info.type
        cls.summary = module_info.summary
        cls.version = utils.Version(module_info.version)
        cls.directory = directory
        return cls
示例#4
0
    def __init__(self, url: str, path: str = None):
        # For some environments where git is not installed, we need to set this environment
        # variable to avoid errors.
        os.environ['GIT_PYTHON_REFRESH'] = 'quiet'
        from git import Repo

        self.url = url
        self.path = os.path.join(SOURCES_HOME, utils.md5(url))

        if self.path.endswith('.git'):
            self.path = self.path[:-4]

        if not os.path.exists(self.path):
            log.logger.info(
                'Git repository {} does not exist, download from remote.'.
                format(self.url))
            self.repo = Repo.clone_from(self.url, self.path)
        else:
            log.logger.info('Git repository {} is located at {}.'.format(
                self.url, self.path))
            self.repo = Repo(self.path)

        self.hub_modules = OrderedDict()
        self.load_hub_modules()
示例#5
0
 def _get_source_key(self, url: str):
     return 'source_{}'.format(utils.md5(url))