From a3c6fd26ad0b34c5ff3f90dd9e053d510b72281f Mon Sep 17 00:00:00 2001 From: pac23 Date: Jul 30 2019 07:38:19 +0000 Subject: print cleanup --- diff --git a/accept.py b/accept.py index 613f325..18a1c49 100644 --- a/accept.py +++ b/accept.py @@ -111,7 +111,7 @@ def accept(args): value = args.issue for x in value: # iteratingover name space object try: - print(x) + #print(x) """ The conversion of X to string below is because to maintin indivual convert @@ -124,7 +124,7 @@ def accept(args): """ issuel = [] issuel.append(x) - print(issuel) + #print(issuel) userstoryid, conversion = convert.convert(issuel, configpath) if conversion == True: print("Sucessfully Converted Issue to User story") diff --git a/bz/bugs.py b/bz/bugs.py index 1345cf4..35b7c2c 100644 --- a/bz/bugs.py +++ b/bz/bugs.py @@ -26,7 +26,7 @@ def post_bug(createinfo, bzapi, config): if not bzapi.logged_in: print("This example requires cached login credentials for %s" % url) bzapi.interactive_login() - print(createinfo) + #print(createinfo) newbug = bzapi.createbug(createinfo) #print(newbug) return newbug @@ -51,7 +51,7 @@ def post_bug(createinfo, bzapi, config): def get_bug(bugid, bzapi, config): if not bzapi.logged_in: bzapi.interactive_login() - print(bugid) + #print(bugid) bug = bzapi.getbug(bugid) return bug """ diff --git a/bz/pgba.py b/bz/pgba.py index d77b4da..6424fb6 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -26,10 +26,10 @@ def pgtobz(value, userstoryid, configpath): for x in value: # iteratingover name space object try: issueurl, r = tgaissue.get_issue(x, config) # x is user story refrence id - print(r) + #print(r) if r.status_code == 200: data = json.loads(r.content) - print(data, "this is user story data") + #print(data, "this is user story data") details = data['description'] subject = data['subject'] taiga_issue_id = data['id'] @@ -52,11 +52,11 @@ def pgtobz(value, userstoryid, configpath): system_wide_change = data['attributes_values']['11370'] relengticket = data['attributes_values']['11371'] fedora_version = data['attributes_values']['11383'] - print(bugzilla_id) - print("this step") + #print(bugzilla_id) + #print("this step") bzid = list(bugzilla_id.split(', ')) - print(bzid) - print(bugzilla_id, " This is bugzilla_id") + #print(bzid) + #print(bugzilla_id, " This is bugzilla_id") try: taiga_issue_link = str(config['TAIGA']['TAIGA_SITE_ISSUE_URL']) + str(taiga_isssue_ref) maillist_link = "random" @@ -110,10 +110,10 @@ def pgtobz(value, userstoryid, configpath): 'title': title, 'issue_content': issue_text } - print(title, payload) + #print(title, payload) repo = config['PAGURE']['RELEASE_NOTES_REPO'] r = pgaissues.post_issue(payload, repo, config) - print(r) + #print(r) if r.status_code == 200: print("Sucessful creation of issue on pagure release notes") return True diff --git a/mail/climail.py b/mail/climail.py index 1b0a38d..4afffe3 100644 --- a/mail/climail.py +++ b/mail/climail.py @@ -58,13 +58,13 @@ def mails(args): reciver = config['EMAIL']['LIST'] log = config['LOG']['LOCATION'] setup_logging_to_file(log) - print(args) + #print(args) value = args.ml for x in value: #for x in value: #ref = input("input the issue no you want to announce: ") try: - print(x) + #print(x) r = issues.get_issue(x, config) if r.status_code == 200: data = json.loads(r.content) diff --git a/mail/maillist.py b/mail/maillist.py index 014b09c..e510dc4 100644 --- a/mail/maillist.py +++ b/mail/maillist.py @@ -48,13 +48,13 @@ def email_send(subject, replyto, config): The answer below the selected/chosen answer """ reciver_emaillist = json.loads(config.get("EMAIL", "LIST")) - print(type(reciver_emaillist)) + #print(type(reciver_emaillist)) #reciver_email = ['manas.man95@gmail.com', 'ttim3886@gmail.com'] #reciver_email = reciver_email.split(',') reciver_email = ', '.join(reciver_emaillist) #reciver_email = reciver - print(type(reciver_email)) - print(reciver_email) + #print(type(reciver_email)) + #print(reciver_email) #reciver_email = ', '.join(reciver) #print(reciver_email) # Enter receiver address """ @@ -66,20 +66,20 @@ def email_send(subject, replyto, config): """ username = keyring.get_password(service_id, "email_username") password = keyring.get_password(service_id, username) - print(password, "this is pass") + #print(password, "this is pass") try: msg = MIMEMultipart() msg['To'] = reciver_emails msg['From'] = username msg['Subject'] = subject - print("this step") + #print("this step") if replyto == True: msg.add_header('reply-to', reciver_email) elif replyto == False: msg.add_header('reply-to', reciver_emaillist[0]) with open("mail.txt", "r") as m_text: data = m_text.read()#.replace('\n', '') - print(data) + #print(data) msg.attach(MIMEText(data, "plain")) # This message is sent from Python.""" context = ssl.create_default_context() diff --git a/pgure/fesco.py b/pgure/fesco.py index 01f7c0f..9035469 100644 --- a/pgure/fesco.py +++ b/pgure/fesco.py @@ -35,7 +35,7 @@ def fesissue(args): r = tgaissue.get_issue(x, config) # x is user story refrence id if r.status_code == 200: data = json.loads(r.content) - print(data, "this is user story data") + #print(data, "this is user story data") details = data['description'] subject = data['subject'] taiga_issue_id = data['id'] @@ -58,10 +58,10 @@ def fesissue(args): system_wide_change = data['attributes_values']['11370'] relengticket = data['attributes_values']['11371'] fedora_version = data['attributes_values']['11383'] - print("this step") + #print("this step") bzid = list(bugzilla_id.split(', ')) - print(bzid) - print(bugzilla_id, " This is bugzilla_id") + #print(bzid) + #print(bugzilla_id, " This is bugzilla_id") try: taiga_issue_link = str(config['TAIGA']['TAIGA_SITE_ISSUE_URL']) + str(taiga_isssue_ref) maillist_link = "random" @@ -78,15 +78,15 @@ def fesissue(args): elif system_wide_change == False: syschange = "Self-Contained Change" title = "F" + str(fedora_version) + ' ' + str(syschange) + ':' + str(subject) - print(issue_text) + #print(issue_text) payload = { 'title': title, 'issue_content': issue_text } - print(title, payload) + #print(title, payload) repo = config['PAGURE']['FESCO_REPO'] r = pgaissues.post_issue(payload, repo, config) - print(r) + #print(r) if r.status_code == 200: payload = { 'status': config['TAIGA']['ISSUE_STATUS_READY_FOR_FESCO'], diff --git a/pgure/issues.py b/pgure/issues.py index 86e8162..6203ca0 100644 --- a/pgure/issues.py +++ b/pgure/issues.py @@ -72,11 +72,11 @@ def post_issue(payload, repo, config): 'Content-Type': 'application/json', 'Authorization': 'token {0}'.format(keyring.get_password(config['PAGURE']['SERVICE_ID'], repo)) } - print(headers) + #print(headers) url = str(config['PAGURE']['API_URL']) + repo + '/new_issue' #print(data) # debug only - print(url) - print(payload) + #print(url) + #print(payload) r = requests.post( url, data=json.dumps(payload), diff --git a/tga/convert.py b/tga/convert.py index 52e7d6c..0af1f18 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -42,7 +42,7 @@ def convert(value, configpath): #value = args.taiga for x in value: try: - print(x,"this is x") + #print(x,"this is x") issueurl, r = tgaissue.get_issue(x, config) # gets the issue if r.status_code == 200: data = json.loads(r.content) @@ -52,10 +52,10 @@ def convert(value, configpath): issue_id = data['id'] issue_ref = data['ref'] issue_version = data['version'] - print(issue_version, "this is issue version") - print("this is issue version") # fetch the id as well + #print(issue_version, "this is issue version") + #print("this is issue version") # fetch the id as well #print(issue_id) - print("Step 1") + #print("Step 1") """ try: Because issue id is required to get custom attributes @@ -77,8 +77,8 @@ def convert(value, configpath): r = tgaissue.caget_issue(issue_id, config) if r.status_code == 200: data = json.loads(r.content) - print(r.content) - print(data, "step 2") + #print(r.content) + #print(data, "step 2") #system_wide_change = data['attributes_values']['1'] # rel-eng-ticket = data['attributes_values']['7'] # bug in taiga thus the later no summary = data['attributes_values'][config['TAIGA']['ISSUE_CA_SUMMARY']] # ['11372'] @@ -92,10 +92,10 @@ def convert(value, configpath): system_wide_change = data['attributes_values'][config['TAIGA']['ISSUE_CA_SYSTEM_WIDE_CHANGE']]#['11370'] relengticket = data['attributes_values'][config['TAIGA']['ISSUE_CA_RELENG_TICKET']]#['11371'] fedora_version = data['attributes_values'][config['TAIGA']['ISSUE_CA_VERSION']]#['11383'] - print(fedora_version) + #print(fedora_version) #print("summary", summary) #print(bugzilla_id) - print("Fetched Custom Attributes") + #print("Fetched Custom Attributes") """ Taiga api returns no's instead of the actual names/description The below no's stand for changes tracker fesco,change-wrangler @@ -123,12 +123,12 @@ def convert(value, configpath): data = json.loads(r.content) #print(r.status_code) if r.status_code == 201: - print("step 3") + #print("step 3") data = json.loads(r.content) userstoryid = data['id'] userstoryref = data['ref'] userstory_version = data['version'] - print(id) + #print(id) issueurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/issue/'+ str(issue_ref) payload = { "attributes_values": { @@ -149,10 +149,10 @@ def convert(value, configpath): }, "version": userstory_version } - print(payload) + #print(payload) r = tgauserstory.post_usca(payload, userstoryid, config) - print(json.loads(r.content)) - print(r.status_code) + #print(json.loads(r.content)) + #print(r.status_code) if r.status_code == 200: print("Sucessfully mapped issue custom attirbutes to userstory") try: @@ -166,7 +166,7 @@ def convert(value, configpath): break r = tgaepic.post_relatedus(userstoryid, epicid, epicref, config) - print(r.content, r.status_code) + #print(r.content, r.status_code) if r.status_code == 201: data = json.loads(r.content) print("Sucessfully mapped epics") @@ -175,12 +175,12 @@ def convert(value, configpath): 'version': userstory_version } r = tgauserstory.changestatus_userstory(userstoryid, payload, config) - print(r.content,r.status_code) + #print(r.content,r.status_code) if r.status_code == 200: userstoryurl = str(config['TAIGA']['PROJECT_WEB_URL']) + str(config['TAIGA']['PROJECT_WEB_NAME']) +'/us/'+ str(userstoryref) issue_version = issue_version # + 1 - print(type(issue_version)) - print(issue_version) + #print(type(issue_version)) + #print(issue_version) payload = { 'version': issue_version, "comment": userstoryurl @@ -196,8 +196,8 @@ def convert(value, configpath): 'version': issue_version } r = tgaissue.changestatus_issue(issue_id, payload, config) - print(r.status_code) - print(r.content) + #print(r.status_code) + #print(r.content) if r.status_code == 200: print("Sucessfully closed issue") return userstoryid, True diff --git a/tga/epics.py b/tga/epics.py index 042ada6..e3d1554 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -40,7 +40,7 @@ def list_epic(config): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/epics?project=" + str(config['TAIGA']['PROJECT_ID']) - print(url) + #print(url) r = requests.get( url, headers=headers diff --git a/tga/issues.py b/tga/issues.py index 496434b..6c0c467 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -37,7 +37,7 @@ def list_issue(args): config = configparser.ConfigParser() config.read(configpath) url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) - print(url) # Debug only + #print(url) # Debug only headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) @@ -53,19 +53,19 @@ def list_issue(args): table.field_names = ["refrence no", "subject", "fedora-version"] data = json.loads(r.content) for item in data: - print(item) + #print(item) due_date = item['due_date'] issueid = item['id'] issueref= item['ref'] subject = item['subject'] version = item['version'] - print(issueref) + #print(issueref) r = caget_issue(issueid, config) if r.status_code == 200: cadata = json.loads(r.content) version = cadata['attributes_values'][config['TAIGA']['ISSUE_CA_VERSION']] #['11383'] else: - print("Error fetching Fedora Version") + print("Error fetching Fedora Version,check logs for errors") """ for item in data['owner_extra_info']: print(item) @@ -75,7 +75,7 @@ def list_issue(args): print(table) else: print("Unable to fetch list check logs") - print(r.content) + #print(r.content) except requests.exceptions.RequestException as e: print(e) log_exception(e) @@ -100,8 +100,8 @@ def get_issue(x, config): # 'Authorization': 'Bearer {0}'.format(str(123)) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/by_ref?ref=" + str(x) + "&project=" + str(config['TAIGA']['PROJECT_ID']) - print(headers) - print(url) # debug/dev env only + #print(headers) + #print(url) # debug/dev env only r = requests.get( url, headers=headers @@ -126,9 +126,9 @@ def caget_issue(x, config): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - print(x) + #print(x) id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) # x is issue id - print(id_url) + #print(id_url) try: r = requests.get( id_url, @@ -149,7 +149,7 @@ def capatch_issue(x, payload, config): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - print(x) + #print(x) id_url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/custom-attributes-values/" + str(x) r = request.patch( id_url, @@ -211,7 +211,7 @@ def edit_issue(x, id, config): data=json.dumps(x), headers=headers ) - print(json.loads(r.content)) + #print(json.loads(r.content)) return r except requests.exceptions.RequestException as e: print(e) @@ -232,7 +232,7 @@ def post_issue(x, config): data=json.dumps(x), headers=headers ) - print(json.loads(r.content)) + #print(json.loads(r.content)) return r except Exception as e: print(e) diff --git a/tga/taiga_auth.py b/tga/taiga_auth.py index d772c92..c6d748a 100644 --- a/tga/taiga_auth.py +++ b/tga/taiga_auth.py @@ -49,20 +49,20 @@ def refresh_token(args): project_id = config['TAIGA']['PROJECT_ID'] taiga_url = config['TAIGA']['TAIGA_URL'] username = keyring.get_password(service_id, "taiga_username") - print(username) # debug only + #print(username) # debug only payload = { 'type': 'normal', 'username': username, 'password': keyring.get_password(service_id, username) } - print(payload) # only for debugging + #print(payload) # only for debugging try: r = requests.post( str(taiga_url) + "/api/v1/auth", data=json.dumps(payload), headers=headers) - print(r.status_code) + #print(r.status_code) if r.status_code == 200: """ with open('auth.txt', 'w') as a_file: @@ -72,8 +72,9 @@ def refresh_token(args): keyring.set_password(service_token, "taiga_token", r.json()['auth_token']) print("succesful authentication") except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to set auth token") - print(e) + print("Failed to set auth token,check log for errors") + #print(e) + log_exception(e) elif r.status_code == 400: print("auth error") except requests.exceptions.RequestException as e: @@ -113,7 +114,7 @@ def reset(args): password = binascii.hexlify(os.urandom(20)) # ranomising pass to avoid sneak memory attacks print("Password reset succesfully") except (keyring.errors.PasswordSetError, Exception) as e: - print("Failed to reset password") + print("Failed to reset password check log for errors") log_exception(e) except Exception as e: print(e) diff --git a/tga/userstory.py b/tga/userstory.py index 901d8f0..350fe98 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -39,17 +39,17 @@ def list_us(args): 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - print(headers) + #print(headers) url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "&status=" + str(config['TAIGA']['USERSTORY_STATUS_NEW']) #url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" - print(url) # Debug only + #print(url) # Debug only try: r = requests.get( url, headers=headers ) if r.status_code == 200: - print(r.status_code) + #print(r.status_code) table = PrettyTable() table.field_names = ["refrence no", "subject", "fedora-version"] data = json.loads(r.content) @@ -70,12 +70,12 @@ def list_us(args): """ table.add_row([USERSTORY_ref, subject, version]) #print(USERSTORY_id, USERSTORY_ref owner) - print(table) + #print(table) else: - print(r.content) + print("check logs for error,unable to process") except requests.exceptions.RequestException as e: print(e) - print(r.content) + #print(r.content) log_exception(e) except Exception as e: print(e) @@ -99,7 +99,7 @@ def get_us(usid, config): #url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(config['TAIGA']['PROJECT_ID']) #url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/" + str(usid) - print(url) # debug only + #print(url) # debug only r = requests.get( url, headers=headers @@ -181,7 +181,7 @@ def post_usca(x, id, config): data=json.dumps(x), headers=headers ) - print(json.loads(r.content)) + #print(json.loads(r.content)) return r except requests.exceptions.RequestException as e: print(e) diff --git a/update.py b/update.py index f6a15a9..1ce1c7f 100644 --- a/update.py +++ b/update.py @@ -50,7 +50,7 @@ def sync(x, config): data = json.loads(r.content) #print(data) for i in data: - print(i['subject']) + #print(i['subject']) if int(i['subject']) == x: epicid = i['id'] epicref = i['ref'] @@ -62,7 +62,7 @@ def sync(x, config): data = json.loads(r.content) for i in data: userstoryid = i['user_story'] - print(userstoryid) + #print(userstoryid) try: r = tgauserstory.get_us(userstoryid, config) if r.status_code == 200: @@ -73,7 +73,7 @@ def sync(x, config): userstorycadata = json.loads(r.content) bztracker = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']] bugid = urlparse(bztracker).query.lstrip("id=") - print(bugid) + #print(bugid) bug = bzbugs.get_bug(bugid, bzapi, config) if bug.status == 'MODIFIED': statusid = config['TAIGA']['USERSTORY_STATUS_TESTABLE'] @@ -129,7 +129,7 @@ def report(x,config): data = json.loads(r.content) #print(data) for i in data: - print(i['subject']) + #print(i['subject']) if int(i['subject']) == x: epicid = i['id'] epicref = i['ref'] @@ -140,7 +140,7 @@ def report(x,config): data = json.loads(r.content) for i in data: userstoryid = i['user_story'] - print(userstoryid) + #print(userstoryid) try: r = tgauserstory.get_us(userstoryid, config) if r.status_code == 200: @@ -159,7 +159,7 @@ def report(x,config): type = userstorycadata['attributes_values'][config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']] status = userstorydata['status_extra_info']['name'] subject = userstorydata['subject'] - print(type, "this is type") + #print(type, "this is type") #record['Updated'] = page.get("last updated") status = userstorydata['status'] @@ -204,14 +204,14 @@ def report(x,config): #print(changes) try: templateLoader = jinja2.FileSystemLoader(searchpath="./" ) - print("this step first before that") + #print("this step first before that") templateEnv = jinja2.Environment( loader=templateLoader ) template = templateEnv.get_template("tplate1.html") - print("this step") + #print("this step") templateVars = {'changes': changes, 'fedoraversion': x} - print(templateVars) + #print(templateVars) outputText = template.render(templateVars) - print(outputText) + #print(outputText) with open("test.html", "w") as rhtml: rhtml.write(outputText) except Exception as e: