Changeset 40 for protocols

Show
Ignore:
Timestamp:
07/17/06 01:07:24 (2 years ago)
Author:
ploum
Message:

#21 cannot add a comment to a bug

First step in bug editing ! Yeah ! I see the light ! I see the light !

Warning : now, Conseil depends from python-mechanize

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • protocols/protocol_launchpadweb.py

    r38 r40  
    55import urllib 
    66from bug import * 
     7from mechanize import Browser 
    78from BeautifulSoup import BeautifulSoup 
    89# You have to change this if you have another storage 
    910from auth_dummy import user 
    1011 
     12baseurl = "https://staging.launchpad.net/" 
     13 
    1114class protocol: 
    1215 
     
    1720# -  user.password() -> string that contains the password 
    1821 
    19  
     22         
    2023################INFORMATION ABOUT THE BTS ################################ 
    2124 
     
    4750                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    4851                # this is what you want to modify to support your own protocol 
    49                 zeurl="https://launchpad.net/bugs/%s" %str(nbr) 
     52                zeurl="%sbugs/%s" %(baseurl,str(nbr)) 
    5053                f= urllib.urlopen(zeurl) 
    5154                # ici on a le corps principal 
     
    109112        def getBugUrl(self,nbr) : 
    110113                bugnbr = str(nbr) 
    111                 return "https://launchpad.net/bugs/%s" %bugnbr 
     114                return "%sbugs/%s" %(baseurl,bugnbr) 
    112115 
    113116 
     
    172175                #inserting dummies bugs 
    173176                plus = search_str.replace(" ","+") 
    174                 zeurl="https://launchpad.net/distros/ubuntu/+bugs?field.searchtext=%s" %plus 
     177                zeurl="%sdistros/ubuntu/+bugs?field.searchtext=%s" %(baseurl,plus) 
    175178                f= urllib.urlopen(zeurl) 
    176179                content=BeautifulSoup(f) 
     
    193196                if search_str != None : 
    194197                        plus = search_str.replace(" ","+") 
    195                         zeurl="https://launchpad.net/distros/ubuntu/+source/%s/+bugs?field.searchtext=%s" %(package,plus) 
     198                        zeurl="%sdistros/ubuntu/+source/%s/+bugs?field.searchtext=%s" %(baseurl,package,plus) 
    196199                else : 
    197                         zeurl="https://launchpad.net/distros/ubuntu/+source/%s/+bugs" %package 
     200                        zeurl="%sdistros/ubuntu/+source/%s/+bugs" %(baseurl,package) 
    198201                f= urllib.urlopen(zeurl) 
    199202                content=BeautifulSoup(f) 
     
    209212                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    210213                # this is what you want to modify to support your own protocol 
    211                 zeurl="https://launchpad.net/products/%s" %package 
     214                zeurl="%sproducts/%s" %(baseurl,package) 
    212215                f= urllib.urlopen(zeurl) 
    213216                #ugly launchpad hack ! 
     
    216219                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%           
    217220         
     221################MODIFYING A BUG ################################# 
     222 
     223        # The functions that will allow us to modify a bug 
     224        # 
     225        # You have to implement the following search modify for your BTS : 
     226        # - postComment(string,string,string) 
     227 
     228        #private function that log the user into Launchpad 
     229        # return a mechanize Browser object 
     230        def __login(self): 
     231                me=user() 
     232                urllog="%s+login" %baseurl 
     233                br = Browser() 
     234                br.set_handle_robots(False) 
     235                br.open(urllog) 
     236                br.select_form(name="login") 
     237                br["loginpage_email"]=me.login() 
     238                br["loginpage_password"]=me.password() 
     239                response = br.submit() 
     240                return br 
     241 
     242        def postComment(self,bugnbr,title,comment) : 
     243                urlcom="%sbugs/%s" %(baseurl,bugnbr) 
     244                br = self.__login() 
     245                br.open(urlcom) 
     246                br.select_form(nr=2) 
     247                # TODO : set the title 
     248                br["field.comment"]= comment 
     249                br.submit() 
     250                 
     251 
     252 
     253         
    218254 
    219255