Exemple #1
0
 def resolve_issue(self, issueKey, resolution='6'):
     '''
     解决ISSUE
     [参数说明]
         issuenum:issue号 
     '''
     try:
         logger.debug('解决jira::%s' % (issueKey))
         self.jira.transition_issue(issueKey, '%s' % ('5'), None, resolution={'id': '%s' % resolution})
     except Exception as e:
         get_except(e)
Exemple #2
0
    def update_fields(self, issue_key, fields_dict):
        """
        更新jira自定义字段:https://jira.readthedocs.io/en/master/examples.html#fields

        :param fields_dict: {'customfield_11403': 1}
        :param issue_key: pms-299
        :returns: this is a description of what is returned
        :raises keyError: raises an exception
        @author: jhuang
        @time:10/10/2018
        """
        issue = self.jira.issue(issue_key)

        for idct_key in fields_dict:
            fields = idct_key

        all_fields_dict = issue.raw['fields']

        text = 0
        for all_fields_dict_one in all_fields_dict:
            if all_fields_dict_one.find(fields):
                text = 1
        if text == 0:
            return 0
        try:
            issue.update(fields=fields_dict)
        except Exception as e:
            return get_except(e)
Exemple #3
0
 def get_avatar(self, username):
     """
     | ##@函数目的: 获取用户头像
     | ##@参数说明:
     | ##@返回值:
     | ##@函数逻辑:
     | ##@开发人:jhuang
     | ##@时间:
     """
     ret, html,respone_time = self.ohttp.get(
         self.confluence_server_url + '/rest/spacedirectory/1/search?label=~' + username + '%3Afavourite&label=~' + username + '%3Afavorite&_=1483072547386')
     try:
         R = re.findall('"image/png" href="(http.*?(?:jpg|png))', html)
         if len(R) > 1:
             return R[1]
         else:
             return None
     except Exception as e:
         get_except(e)
         return None
Exemple #4
0
def crontab_parse(crontabs, LineList=False):
    """
    |##@Function purpose:解析Crontab
    |##@Parameter description:None
    |##@Return value:None
    |##@Function logic:None
    |##@author: jhuang
    |##@time:
    """
    try:
        print crontabs
        crontabs = re.findall('^(?:\d+|\*).*?\s+.*?\s+.*?\s+.*?\s+.*?\s+.*',
                              crontabs, re.M)
        crontab_list = []
        if LineList:
            for r in crontabs:
                crontab_list.append(r.strip().strip('\n').strip('\r'))
            return crontab_list

        print crontabs
        for crontab in crontabs:
            dic = {}
            # print crontab
            dic['interval'] = str(
                re.findall('(^(?:\d+|\*).*?\s+.*?\s+.*?\s+.*?\s+.*?\s+)(.*)',
                           crontab,
                           re.M)[0][0]).strip().strip('\n').strip('\r')
            dic['what'] = str(
                re.findall('(^(?:\d+|\*).*?\s+.*?\s+.*?\s+.*?\s+.*?\s+)(.*)',
                           crontab,
                           re.M)[0][1]).strip().strip('\n').strip('\r')
            crontab = crontab.replace(' ', '')
            crontab_list.append(dic)
        return crontab_list
    except Exception as e:
        get_except(e)
        return []
Exemple #5
0
        def inner_wrapper(*args, **kwargs):
            try:
                start_time = time.time()

                ret = func(*args, **kwargs)
                # logger.debug('函数(%s)用时:%s' % (__name__,time.time() - start_time))
                print '函数(%s)用时(s):%s' % (func.__name__,
                                          time.time() - start_time)

                return ret
            except Exception as e:
                # pass
                logger.exception('view_except')

                return response_json(get_except(e), error_code=error_code)

                # re-raise the exception
                raise
Exemple #6
0
 def status_code(self, url):
     """
     | ##@函数目的: 状态码
     | ##@参数说明:
     | ##@返回值:
     | ##@函数逻辑:
     | ##@开发人:jhuang
     | ##@时间:
     """
     status_code = ''
     try:
         r = self.session.get(url,
                              stream=True,
                              headers=self.headers,
                              timeout=self.timeout,
                              verify=self.verify)
         status_code = str(r.status_code)
     except Exception as e:
         status_code = get_except(e, False, write_log=False)
         # status_code = get_except(e, False)
     return str(status_code)