def new(self, **kwargs): """Opens new bug It automatically generates bug_url from product as bugzilla wants product name in GET response Args: product: Product name in the site component: Component name in bugzilla page security: Whether it is security vulnerability url: External url status: Initial but status. (NEW, RESOLVED) assigned_to: Email address to assign alias: Bug alias (NOT IMPLEMENTED) blocks: Bugs that this bug blocks dependson: Bug that depends on. cc: E-mail addresses to CC Returns: Integer indicating the bugzilla id for new bug Raises: BugzillaError: Required arguments are not provided """ log = logging.getLogger("bugzilla.NEW") args = BugStruct(**kwargs) # control required vars if not (args.has("component") and args.has("product") and args.has("title") and args.has("description")): raise BugzillaError( "Missing argument. Component, Product, Title and Description are needed" ) bug_url = self.constants.get_new_bug_url(args.product) log.debug("Opening new bug page") self.browser.open(bug_url) log.debug("Selecting form name: Create") self.browser.select_form(name="Create") log.debug("Adding component, title and comment") self.browser["component"] = [args.component] self.browser["short_desc"] = args.title self.browser["comment"] = args.description if args.has("url"): log.debug("URL: %s" % args.url) self.browser["bug_file_loc"] = args.url if args.has("security"): log.debug("Security: 1") self.browser["bit-10"] = ["1"] if args.has("status"): log.debug("Bug_status: %s" % args.status) self.browser["bug_status"] = [args.status] if args.has("assigned_to"): log.debug("Assign: %s" % args.assigned_to) self.browser["assigned_to"] = args.assigned_to if args.has("dependson"): log.debug("Depends on: %s" % args.dependson) self.browser["dependson"] = args.dependson if args.has("blocks"): log.debug("Blocks: %s" % args.blocks) self.browser["blocked"] = args.blocks if args.has("version"): log.debug("Version: %s" % args.version) self.browser["version"] = [args.version] if args.has("cc"): log.debug("CC: %s" % args.cc) self.browser["cc"] = args.cc # FIXME: Our bugzilla page doesn't show alias field. # FIXME: Uncomment it when it is done # if args.has("alias"): # self.browser["alias"] = args.alias response = self.browser.submit() response = response.read() log.info("Bug submitted") # get bug id. re_compile = re.compile("Bug (.*?) Submitted") bug_id = re.findall(re_compile, response) if len(bug_id) != 0: return bug_id[0] else: log.error("Wohoops. Unexpected data returned after submitting.") return False
def new(self, **kwargs): """Opens new bug It automatically generates bug_url from product as bugzilla wants product name in GET response Args: product: Product name in the site component: Component name in bugzilla page security: Whether it is security vulnerability url: External url status: Initial but status. (NEW, RESOLVED) assigned_to: Email address to assign alias: Bug alias (NOT IMPLEMENTED) blocks: Bugs that this bug blocks dependson: Bug that depends on. cc: E-mail addresses to CC Returns: Integer indicating the bugzilla id for new bug Raises: BugzillaError: Required arguments are not provided """ log = logging.getLogger("bugzilla.NEW") args = BugStruct(**kwargs) # control required vars if not (args.has("component") and args.has("product") and args.has("title") and args.has("description")): raise BugzillaError("Missing argument. Component, Product, Title and Description are needed") bug_url = self.constants.get_new_bug_url(args.product) log.debug("Opening new bug page") self.browser.open(bug_url) log.debug("Selecting form name: Create") self.browser.select_form(name="Create") log.debug("Adding component, title and comment") self.browser["component"] = [args.component] self.browser["short_desc"] = args.title self.browser["comment"] = args.description if args.has("url"): log.debug("URL: %s" % args.url) self.browser["bug_file_loc"] = args.url if args.has("security"): log.debug("Security: 1") self.browser["bit-10"] = ["1"] if args.has("status"): log.debug("Bug_status: %s" % args.status) self.browser["bug_status"] = [args.status] if args.has("assigned_to"): log.debug("Assign: %s" % args.assigned_to) self.browser["assigned_to"] = args.assigned_to if args.has("dependson"): log.debug("Depends on: %s" % args.dependson) self.browser["dependson"] = args.dependson if args.has("blocks"): log.debug("Blocks: %s" % args.blocks) self.browser["blocked"] = args.blocks if args.has("version"): log.debug("Version: %s" % args.version) self.browser["version"] = [args.version] if args.has("cc"): log.debug("CC: %s" % args.cc) self.browser["cc"] = args.cc # FIXME: Our bugzilla page doesn't show alias field. # FIXME: Uncomment it when it is done # if args.has("alias"): # self.browser["alias"] = args.alias response = self.browser.submit() response = response.read() log.info("Bug submitted") # get bug id. re_compile = re.compile("Bug (.*?) Submitted") bug_id = re.findall(re_compile, response) if len(bug_id) != 0: return bug_id[0] else: log.error("Wohoops. Unexpected data returned after submitting.") return False
def modify(self, **kwargs): # TODO: Implement Product/Component/CC list """Modifies the bug. All arguments can be supplied. This function modifies the form on the page and submits just like an ordinary browser does. Args: bug_id: Bug id to edit title: New bug title comment: Comment to write status: Status (NEW, ASSIGNED, RESOLVED) resolution: (FIXED, INVALID, WONTFIX, LATER, REMIND, DUPLICATE) security: Whether it is security or not assigned_to: E-mail address to assign a bug blocks: Bugs that this bug blocks dependson: Bug that depends on. cc: Add e-mail address to cc list Raises: BugzillaError: You should first login to modify the bug ModifyError: Changes are not applied """ log = logging.getLogger("bugzilla.MODIFY") args = BugStruct(**kwargs) if not args.has("bug_id"): raise BugzillaError("Bug id is needed to modify") if not self.is_logged_in: log.error("Login is needed") raise LoginError("You should first login to comment") log.info("Opening bug #%s to modify" % args.bug_id) bug_data = self._bug_open(args.bug_id, xml=False) # do we have permission to see this bug? if bug_data.find(self.constants.NO_PERMISSON_STRING) > -1: log.error("Don't have permission to modify the bug") raise BugzillaError("You don't have permission to see this bug") log.info("Opened bug #%s page" % args.bug_id) log.debug("Selecting changeform") self.browser.select_form(name="changeform") # for x in self.browser.forms(): # print x if args.has("title"): log.debug("New title: %s" % args.title) self.browser["short_desc"] = args.title if args.has("status"): log.debug("Bug_status: %s" % args.status) self.browser["bug_status"] = [args.status] if args.has("resolution"): log.debug("Resolution: %s" % args.resolution) self.browser["resolution"] = [args.resolution] if args.has("comment"): log.debug("Setting comment") self.browser["comment"] = args.comment if args.has("security"): # Pardus has specific setting for security vulnerabilities that will not be public. The checkbox name is "bit-10" log.debug("Marking as security") if args.security == "1": # if the bug has bit-10 field set if len(self.browser["bit-10"]) != 0: log.warning( "Bug is already in security group, not setting security tag" ) else: self.browser["bit-10"] = ["1"] # marking as non-security else: if len(self.browser["bit-10"]) == 0: log.warning( "Bug is already public, not setting security tag..") else: self.browser["bit-10"] = [] if args.has("assigned_to"): log.debug("Assigned: %s" % args.assigned_to) self.browser["assigned_to"] = args.assigned_to if args.has("keywords"): log.debug("Keywords: %s" % args.keywords) self.browser["keywords"] += ", %s" % args.keywords if args.has("dependson"): log.debug("Dependson: %s" % args.dependson) self.browser["dependson"] = args.dependson if args.has("blocks"): log.debug("Blocks: %s" % args.blocks) self.browser["blocked"] = args.blocks if args.has("cc"): log.debug("CC: %s" % args.cc) self.browser["newcc"] = args.cc if args.has("version"): log.debug("Version: %s" % args.version) self.browser["version"] = [args.version] log.info("Submitting the changes") response = self.browser.submit() response = response.read() # is everything alright? if response.find(self.constants.BUG_PROCESS_OK_STRING) > -1: log.info("Changes have been submitted") return True else: # something is wrong. log.error("Errr, something is wrong in returned value.") #print response raise ModifyError("Unexpected return value", response)
def modify(self, **kwargs): # TODO: Implement Product/Component/CC list """Modifies the bug. All arguments can be supplied. This function modifies the form on the page and submits just like an ordinary browser does. Args: bug_id: Bug id to edit title: New bug title comment: Comment to write status: Status (NEW, ASSIGNED, RESOLVED) resolution: (FIXED, INVALID, WONTFIX, LATER, REMIND, DUPLICATE) security: Whether it is security or not assigned_to: E-mail address to assign a bug blocks: Bugs that this bug blocks dependson: Bug that depends on. cc: Add e-mail address to cc list Raises: BugzillaError: You should first login to modify the bug ModifyError: Changes are not applied """ log = logging.getLogger("bugzilla.MODIFY") args = BugStruct(**kwargs) if not args.has("bug_id"): raise BugzillaError("Bug id is needed to modify") if not self.is_logged_in: log.error("Login is needed") raise LoginError("You should first login to comment") log.info("Opening bug #%s to modify" % args.bug_id) bug_data = self._bug_open(args.bug_id, xml=False) # do we have permission to see this bug? if bug_data.find(self.constants.NO_PERMISSON_STRING) > -1: log.error("Don't have permission to modify the bug") raise BugzillaError("You don't have permission to see this bug") log.info("Opened bug #%s page" % args.bug_id) log.debug("Selecting changeform") self.browser.select_form(name="changeform") # for x in self.browser.forms(): # print x if args.has("title"): log.debug("New title: %s" % args.title) self.browser["short_desc"] = args.title if args.has("status"): log.debug("Bug_status: %s" % args.status) self.browser["bug_status"] = [args.status] if args.has("resolution"): log.debug("Resolution: %s" % args.resolution) self.browser["resolution"] = [args.resolution] if args.has("comment"): log.debug("Setting comment") self.browser["comment"] = args.comment if args.has("security"): # Pardus has specific setting for security vulnerabilities that will not be public. The checkbox name is "bit-10" log.debug("Marking as security") if args.security == "1": # if the bug has bit-10 field set if len(self.browser["bit-10"]) != 0: log.warning("Bug is already in security group, not setting security tag") else: self.browser["bit-10"] = ["1"] # marking as non-security else: if len(self.browser["bit-10"]) == 0: log.warning("Bug is already public, not setting security tag..") else: self.browser["bit-10"] = [] if args.has("assigned_to"): log.debug("Assigned: %s" % args.assigned_to) self.browser["assigned_to"] = args.assigned_to if args.has("keywords"): log.debug("Keywords: %s" % args.keywords) self.browser["keywords"] += ", %s" % args.keywords if args.has("dependson"): log.debug("Dependson: %s" % args.dependson) self.browser["dependson"] = args.dependson if args.has("blocks"): log.debug("Blocks: %s" % args.blocks) self.browser["blocked"] = args.blocks if args.has("cc"): log.debug("CC: %s" % args.cc) self.browser["newcc"] = args.cc if args.has("version"): log.debug("Version: %s" % args.version) self.browser["version"] = [args.version] log.info("Submitting the changes") response = self.browser.submit() response = response.read() # is everything alright? if response.find(self.constants.BUG_PROCESS_OK_STRING) > -1: log.info("Changes have been submitted") return True else: # something is wrong. log.error("Errr, something is wrong in returned value.") #print response raise ModifyError("Unexpected return value", response)