- Timestamp:
- 07/17/06 01:07:24 (2 years ago)
- Files:
-
- 1 modified
-
protocols/protocol_launchpadweb.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
protocols/protocol_launchpadweb.py
r38 r40 5 5 import urllib 6 6 from bug import * 7 from mechanize import Browser 7 8 from BeautifulSoup import BeautifulSoup 8 9 # You have to change this if you have another storage 9 10 from auth_dummy import user 10 11 12 baseurl = "https://staging.launchpad.net/" 13 11 14 class protocol: 12 15 … … 17 20 # - user.password() -> string that contains the password 18 21 19 22 20 23 ################INFORMATION ABOUT THE BTS ################################ 21 24 … … 47 50 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48 51 # 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)) 50 53 f= urllib.urlopen(zeurl) 51 54 # ici on a le corps principal … … 109 112 def getBugUrl(self,nbr) : 110 113 bugnbr = str(nbr) 111 return " https://launchpad.net/bugs/%s" %bugnbr114 return "%sbugs/%s" %(baseurl,bugnbr) 112 115 113 116 … … 172 175 #inserting dummies bugs 173 176 plus = search_str.replace(" ","+") 174 zeurl=" https://launchpad.net/distros/ubuntu/+bugs?field.searchtext=%s" %plus177 zeurl="%sdistros/ubuntu/+bugs?field.searchtext=%s" %(baseurl,plus) 175 178 f= urllib.urlopen(zeurl) 176 179 content=BeautifulSoup(f) … … 193 196 if search_str != None : 194 197 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) 196 199 else : 197 zeurl=" https://launchpad.net/distros/ubuntu/+source/%s/+bugs" %package200 zeurl="%sdistros/ubuntu/+source/%s/+bugs" %(baseurl,package) 198 201 f= urllib.urlopen(zeurl) 199 202 content=BeautifulSoup(f) … … 209 212 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 210 213 # this is what you want to modify to support your own protocol 211 zeurl=" https://launchpad.net/products/%s" %package214 zeurl="%sproducts/%s" %(baseurl,package) 212 215 f= urllib.urlopen(zeurl) 213 216 #ugly launchpad hack ! … … 216 219 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 217 220 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 218 254 219 255
