Exemplo n.º 1
0
Arquivo: bugz2.py Projeto: timbr/-Bugz
def createdict(bug, force='false'):
    if bug not in bugz.keys() or force == 'force':
        xmlfile = toolbox.geturl('http://bugzilla/spddesign/show_bug.cgi?ctype=xml&id=' + bug)
    
        print "Getting bug " + bug

        tree = etree.parse(xmlfile)
        root = tree.getroot()
        
        if bug in bugz.keys():
            bugz.pop(bug) # delete existing entry

        comment={}
        i=0
        for entry in root[0].findall('long_desc'):
            comment[i] = {'who': entry[0].text, 'when': entry[1].text, 'thetext': escapeunicode(entry[2].text)}
            i += 1

        bugz[str(root[0].find('bug_id').text)] = {
            'Desc': escapeunicode(root[0].find('short_desc').text),
            'Status': root[0].find('bug_status').text,
            'Topic': root[0].find('product').text,
            'Dependson': [depon.text for depon in root[0].findall('dependson')],
            'Blocks': [blck.text for blck in root[0].findall('blocked')],
            'Reporter': root[0].find('reporter').text,
            'Assignedto': root[0].find('assigned_to').text,
            'CC': [copy.text for copy in root[0].findall('cc')],
            'Comment': comment
            }
    #print bug
    for blocker in bugz[bug]['Dependson']:
        if str(blocker) not in bugz.keys():
            #print blocker
            createdict(str(blocker))
Exemplo n.º 2
0
Arquivo: bugz2.py Projeto: timbr/-Bugz
def updatelocaldb():
    if 'lastupdated' in bugz.keys():
        dbLastUpdated = bugz['lastupdated']
    else:
        dbLastUpdated = datetime.datetime(2007, 01, 01)
        
    timeformat = format = "%Y-%m-%d"
    one_day = datetime.timedelta(days=1)
    today = datetime.datetime.today()
    #yesterday = (today - one_day).strftime(timeformat)
    day_before_last_updated = (dbLastUpdated - one_day).strftime(timeformat)
    urlstring = "\
http://bugzilla/spddesign/buglist.cgi?bug_file_loc=&bug_file_loc_type=allwordssubstr&\
bug_id=&bugidtype=include&chfieldfrom=" + day_before_last_updated + "&chfieldto=Now&chfieldvalue=&deadlinefrom=&\
deadlineto=&email1=&email2=&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1\
&emailreporter2=1&emailtype1=substring&emailtype2=substring&field-1-0-0=product\
&field0-0-0=noop&long_desc=&long_desc_type=substring&product=CXY%20Stage\
&product=Divisional%20Meeting%20Actions&product=inVia%20Cont.%20Eng.&product=inVia%20Specials\
&product=RA801%20D3&product=RA802%20Pharma&product=RenCam2&product=SEM-SCA&query_format=advanced\
&remaction=&short_desc=&short_desc_type=allwordssubstr&type-1-0-0=anyexact&type0-0-0=noop\
&value-1-0-0=CXY%20Stage%2CDivisional%20Meeting%20Actions%2CinVia%20Cont.%20Eng.%2CinVia%20\
Specials%2CRA801%20D3%2CRA802%20Pharma%2CRenCam2%2CSEM-SCA&value0-0-0=&title=Issue%20List&ctype=atom"
    
    xmlfile = toolbox.geturl(urlstring)
    tree = etree.parse(xmlfile)
    root = tree.getroot()
    
    for entry in root.findall('{http://www.w3.org/2005/Atom}entry'):
        for title in entry.findall('{http://www.w3.org/2005/Atom}title'):
            changedbugs =  str(title.text.split(']')[0][7:]) # This was causing me a problem because the title was unicode whihc made the bug number unicode
            createdict(changedbugs, 'force')
            #createdict(changedbugs)
    
    bugz['lastupdated'] = today