def auth(self, service, username, password, verify=True): self._userName = username self._service = service self._stash = stashy.connect(service, username, password, verify=verify) numAttempts = 0 success = False while numAttempts < 3 and not success: try: self._stash.projects.list() success = True except stashy.errors.AuthenticationException: if numAttempts == 0: print("session expired...") else: print("incorrect username / password...") self._userName = utility.getUserName(self._userName) keyring.set_password( service, self._userName, getpass.getpass("Enter password for %s: " % service)) self._stash = stashy.connect(service, self._userName, keyring.get_password( service, self._userName), verify=verify) numAttempts += 1 return success
def con_str(): user_id = utility.getUserId(utility.getUserName()) db = database_connection() cursor = db.cursor() string2="" sql_role = 'select role_id from mapping where user_id = %s' %user_id cursor.execute(sql_role) results_role=cursor.fetchall() for row in results_role: role_id = row[0] sql_keyword = 'select keywords,emails,names from mapping where role_id = %s' %role_id cursor.execute(sql_keyword) results_keyword=cursor.fetchall() for row1 in results_keyword: keyword = row1[0] if keyword: string2 = keyword+";"+string2 emails = row1[1] if emails: string2 =emails+";"+string2 names = row1[2] if names: string2 =names+";"+string2 sql_user = '******' %user_id cursor.execute(sql_user) results_user=cursor.fetchall() for rows in results_user: user_name = rows[0] return (string2,user_name)
def __init__(self, username = None): if username is None: self.userName = utility.getUserName() else: self.userName = username self.stash = TestStash() print("Connected to Bitbucket")
def __init__(self, username=None): if username is None: self.userName = utility.getUserName() else: self.userName = username self.stash = TestStash() print("Connected to Bitbucket")
def getLocal(): user_id = utility.getUserId(utility.getUserName()) db = database_connection() cursor = db.cursor() sql = "select gmail_login,gmail_pwd,login_id from user where user_id='%s'" %user_id cursor.execute(sql) results = cursor.fetchall() for row in results: local = row[2] return local
def getGmailAcct(): user_id = utility.getUserId(utility.getUserName()) db = database_connection() cursor = db.cursor() sql = "select gmail_login,gmail_pwd,login_id from user where user_id='%s'" %user_id #%(getUserName()) #print sql cursor.execute(sql) results = cursor.fetchall() for row in results: username= row[0] password = row[1] local = row[2] #print username return (username,password,local)
def __init__(self, username=None, url=rzbitbucketURL, verify=True): if username is None: self._userName = utility.getUserName() else: self._userName = username self.keyring = keyring.get_keyring() self._service = url password = keyring.get_password(self._service, self._userName) if self.auth(self._service, self._userName, password, verify=verify): self.url = url print("Connected to Bitbucket.") else: self._stash = None print("Could not connect to Bitbucket...")
def execute(self, args): start = args["--start"] if not start: start = self._public # decide whether to recurse recurse = grapeConfig.grapeConfig().get('workspace', 'manageSubmodules') if args["--recurse"]: recurse = True if args["--noRecurse"]: recurse = False if not args["<descr>"]: args["<descr>"] = utility.userInput( "Enter one word description for branch:") if not args["--user"]: args["--user"] = utility.getUserName() branchName = self._key + "/" + args["--user"] + "/" + args["<descr>"] launcher = utility.MultiRepoCommandLauncher(createBranch, runInSubmodules=recurse, runInSubprojects=recurse, runInOuter=True, branch=start, globalArgs=branchName) launcher.initializeCommands() utility.printMsg("About to create the following branches:") for repo, branch in zip(launcher.repos, launcher.branches): utility.printMsg("\t%s off of %s in %s" % (branchName, branch, repo)) proceed = utility.userInput("Proceed? [y/n]", default="y") if proceed: grapeMenu.menu().applyMenuChoice( 'up', ['up', '--public=%s' % start]) launcher.launchFromWorkspaceDir() else: utility.printMsg("branches not created")
def execute(self, args): start = args["--start"] if not start: start = self._public # decide whether to recurse recurse = grapeConfig.grapeConfig().get('workspace', 'manageSubmodules') if args["--recurse"]: recurse = True if args["--noRecurse"]: recurse = False if not args["<descr>"]: args["<descr>"] = utility.userInput("Enter one word description for branch:") if not args["--user"]: args["--user"] = utility.getUserName() branchName = self._key + "/" + args["--user"] + "/" + args["<descr>"] launcher = utility.MultiRepoCommandLauncher(createBranch, runInSubmodules=recurse, runInSubprojects=recurse, runInOuter=True, branch=start, globalArgs=branchName) launcher.initializeCommands() utility.printMsg("About to create the following branches:") for repo, branch in zip(launcher.repos, launcher.branches): utility.printMsg("\t%s off of %s in %s" % (branchName, branch, repo)) proceed = utility.userInput("Proceed? [y/n]", default="y") if proceed: grapeMenu.menu().applyMenuChoice('up', ['up', '--public=%s' % start]) launcher.launchFromWorkspaceDir() else: utility.printMsg("branches not created")
def auth(self, service, username, password, verify=True): self._userName = username self._service = service self._stash = stashy.connect(service, username, password, verify=verify) numAttempts = 0 success = False while numAttempts < 3 and not success: try: self._stash.projects.list() success = True except stashy.errors.AuthenticationException: if numAttempts == 0: print("session expired...") else: print("incorrect username / password...") self._userName = utility.getUserName(self._userName) keyring.set_password(service, self._userName, getpass.getpass("Enter password for %s: " % service)) self._stash = stashy.connect(service, self._userName, keyring.get_password(service, self._userName), verify=verify) numAttempts += 1 return success
def main(): form = cgi.FieldStorage() if(form.has_key("action")): customer_id = utility.getUserId(utility.getUserName()) if form["action"].value == "display": if "keyword" not in form: keywords= "" else: keywords = form["keyword"].value if "email" not in form: emails= "" else: emails = form["email"].value if "name" not in form: names= "" else: names = form["name"].value insert_roles(customer_id,form["role_name"].value,keywords,emails,names) else: generate_form(0)
def execute(self, args): """ A fair chunk of this stuff relies on stashy's wrapping of the STASH REST API, which is posted at https://developer.atlassian.com/static/rest/stash/2.12.1/stash-rest.html """ config = grapeConfig.grapeConfig() name = args["--user"] if not name: name = utility.getUserName() utility.printMsg("Logging onto %s" % args["--bitbucketURL"]) if args["--test"]: bitbucket = Atlassian.TestAtlassian(name) else: verify = True if args["--verifySSL"].lower() == "true" else False bitbucket = Atlassian.Atlassian(name, url=args["--bitbucketURL"], verify=verify) # default project (outer level project) project_name = args["--project"] # default repo (outer level repo) repo_name = args["--repo"] # determine source branch and target branch branch = args["--source"] if not branch: branch = git.currentBranch() # make sure we are in the outer level repo before we push wsDir = utility.workspaceDir() os.chdir(wsDir) #ensure branch is pushed utility.printMsg("Pushing %s to bitbucket..." % branch) git.push("origin %s" % branch) #target branch for outer level repo target_branch = args["--target"] if not target_branch: target_branch = config.getPublicBranchFor(branch) # load pull request from Bitbucket if it already exists wsRepo = bitbucket.project(project_name).repo(repo_name) existingOuterLevelRequest = getReposPullRequest( wsRepo, branch, target_branch, args) # determine pull request title title = args["--title"] if existingOuterLevelRequest is not None and not title: title = existingOuterLevelRequest.title() #determine pull request URL outerLevelURL = None if existingOuterLevelRequest: outerLevelURL = existingOuterLevelRequest.link() # determine pull request description descr = self.parseDescriptionArgs(args) if not descr and existingOuterLevelRequest: descr = existingOuterLevelRequest.description() # determine pull request reviewers reviewers = self.parseReviewerArgs(args) if reviewers is None and existingOuterLevelRequest is not None: reviewers = [r[0] for r in existingOuterLevelRequest.reviewers()] # if we're in append mode, only append what was asked for: if args["--append"] or args["--prepend"]: title = args["--title"] descr = self.parseDescriptionArgs(args) reviewers = self.parseReviewerArgs(args) ## Submodule Repos missing = utility.getModifiedInactiveSubmodules(target_branch, branch) if missing: utility.printMsg( "The following submodules that you've modified are not currently present in your workspace.\n" "You should activate them using grape uv and then call grape review again. If you haven't modified " "these submodules, you may need to do a grape md to proceed.") utility.printMsg(','.join(missing)) return False pullRequestLinks = {} if not args["--norecurse"] and (args["--recurse"] or config.getboolean( "workspace", "manageSubmodules")): modifiedSubmodules = git.getModifiedSubmodules( target_branch, branch) submoduleBranchMappings = config.getMapping( "workspace", "submoduleTopicPrefixMappings") for submodule in modifiedSubmodules: if not submodule: continue # push branch os.chdir(submodule) utility.printMsg("Pushing %s to bitbucket..." % branch) git.push("origin %s" % branch) os.chdir(wsDir) repo = bitbucket.repoFromWorkspaceRepoPath(submodule, isSubmodule=True) # determine branch prefix prefix = branch.split('/')[0] sub_target_branch = submoduleBranchMappings[prefix] prevSubDescr = getReposPullRequestDescription( repo, branch, sub_target_branch, args) #amend the subproject pull request description with the link to the outer pull request subDescr = addLinkToDescription(descr, outerLevelURL, True) if args["--prepend"] or args["--append"]: subDescr = descr newRequest = postPullRequest(repo, title, branch, sub_target_branch, subDescr, reviewers, args) if newRequest: pullRequestLinks[newRequest.link()] = True else: # if a pull request could not be generated, just add a link to browse the branch pullRequestLinks[ "%s%s/browse?at=%s" % (bitbucket.rzbitbucketURL, repo.repo.url(), urllib.quote_plus("refs/heads/%s" % branch))] = False ## NESTED SUBPROJECT REPOS nestedProjects = grapeConfig.GrapeConfigParser.getAllModifiedNestedSubprojects( target_branch) nestedProjectPrefixes = grapeConfig.GrapeConfigParser.getAllModifiedNestedSubprojectPrefixes( target_branch) for proj, prefix in zip(nestedProjects, nestedProjectPrefixes): with utility.cd(prefix): git.push("origin %s" % branch) repo = bitbucket.repoFromWorkspaceRepoPath(proj, isSubmodule=False, isNested=True) newRequest = postPullRequest(repo, title, branch, target_branch, descr, reviewers, args) if newRequest: pullRequestLinks[newRequest.link()] = True else: # if a pull request could not be generated, just add a link to browse the branch pullRequestLinks["%s%s/browse?at=%s" % (bitbucket.rzbitbucketURL, repo.repo.url(), urllib.quote_plus( "refs/heads/%s" % branch))] = False ## OUTER LEVEL REPO # load the repo level REST resource if not args["--subprojectsOnly"]: if not git.hasBranch(branch): utility.printMsg( "Top level repository does not have a branch %s, not generating a Pull Request" % (branch)) return True if git.branchUpToDateWith(target_branch, branch): utility.printMsg( "%s up to date with %s, not generating a Pull Request in Top Level repo" % (target_branch, branch)) return True repo_name = args["--repo"] repo = bitbucket.repoFromWorkspaceRepoPath( wsDir, topLevelRepo=repo_name, topLevelProject=project_name) utility.printMsg("Posting pull request to %s,%s" % (project_name, repo_name)) request = postPullRequest(repo, title, branch, target_branch, descr, reviewers, args) updatedDescription = request.description() for link in pullRequestLinks: updatedDescription = addLinkToDescription( updatedDescription, link, pullRequestLinks[link]) if updatedDescription != request.description(): request = postPullRequest(repo, title, branch, target_branch, updatedDescription, reviewers, args) utility.printMsg("Request generated/updated:\n\n%s" % request) return True
def insert_data(): user_id = utility.getUserId(utility.getUserName()) #print user_id #data = [('googlecalendar', '\t\t\tName: [email protected]\n\t\t\temail: [email protected]', '\t\t\t2010-12-05\n\t\t\t15:00:00\n', '\ttest attachment 1\n', '\tthis is a test1', "[u'NULL']", ['ritu', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test']), ('googlecalendar', '\t\t\tName: [email protected]\n\t\t\temail: [email protected]', '\t\t\t2010-12-05\n\t\t\t15:00:00\n', '\ttest event 2\n', '\tthis is a test2', "[u'NULL']", ['deepali', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test']), ('googlecalendar','\t\t\tName: [email protected]\n\t\t\temail: [email protected]', '\t\t\t2010-12-05\n\t\t\t15:00:00\n', '\ttest event\n', '\tthis is a test', "[u'NULL']", ['johann'])] wordList,local = con_str.con_str() data = runner.xmlReadandAnalyze(wordList,local) #print "Data:%s"%data #[('gmail', 'Deepali Agarwal <*****@*****.**>', '2010-12-05 17:45:09', 'urgent', ' Hi this is an urgent message.\n\n-- \nThanks and Regards!\nDeepali\n', "[u'NULL']", ['urgent'])] #data = [('Brandeis Now', ' Brandeis Now', ' 2010-12-03 17:06:00', ' Town hall on alcohol and drug policy', ' ', "[u'http://www.brandeis.edu/now/2010/december/townhall-dec6.html']", []), ('Brandeis Now', ' Brandeis Now', ' 2010-11-30 14:28:00', ' Schusterman Center unveils Israeli art collection', " At the entrance to the new home of the Schusterman Center for Israel Studies, on the top level of the Mandel Center for the Humanities, visitors encounter innovative video works by prominent Israeli artists. These works by Sigalit Landau, Yael Bartana, Doron Solomons and Guy Ben-Ner are on display here after having been screened at major museums, among them the Israel Museum in Jerusalem, the Museum of Modern Art in New York, Tate Modern in London, and the Massachusetts Museum of Contemporary Art. They are part of a new collection of contemporary Israeli photography, prints and video art unveiled Nov. 10 at the inauguration of the Schusterman Center's new space. Also on display in the center are several large and powerful photographs of the Israeli landscape, including a nostalgic vista of the Yarkon River by Yossi Breger and a nocturnal image of the ruins of a Palestinian home by Dor Guez.", "[u'http://www.brandeis.edu/now/2010/december/schustermanfeature.html']", []), ('Brandeis Now', ' Brandeis Now', ' 2010-11-29 21:07:00', ' Annual Messiah Sing', ' ', "[u'http://www.brandeis.edu/arts/concerts/concerts.html']", []), ('Brandeis Now', ' Brandeis Now', ' 2010-11-29 17:48:00', " 'Girldrive' author says her cross-country trip shaped her view of feminism", ' In 2007, journalist and cultural critic Nona Willis Aronowitz and photographer Emma Bee Bernstein, both then 22 years old, hit the road for a trip across the United States to discover how their generation of young women related to feminism and ideas about gender justice. Some who they met didn\'t know the word "feminist," but they were "living the legacy" of feminism, she says.', "[u'http://www.brandeis.edu/now/2010/november/girldrive.html']", []), ('Brandeis Now', ' Brandeis Now', ' 2010-11-29 17:33:00', ' Ambassador will speak on South Sudan referendum', ' The self-determination vote gives South Sudan the opportunity to vote for independence from the North. The vote was provided for in the Comprehensive Peace Agreement that ended the Sudanese civil war in 2005. Top officials on both sides have committed to holding the referendum on time and to respecting the outcome. But many in the South and the international community worry that the government in Khartoum, in North Sudan, will not go along if the South votes for independence. ', "[u'http://www.brandeis.edu/now/2010/november/sudanese.html']", []), ('Brandeis Now', ' Brandeis Now', ' 2010-11-29 16:28:00', ' Staff awards surprise recipients', ' ', "[u'http://www.brandeis.edu/now/2010/november/staffawards.html']", [])] keywords = [] counter = 0 for item in data: counter +=1 #print "counter" #print counter source = item[0] email_from = item[1] email_date = item[2] subject = item[3] message = item[4] attachment = item[5] keywords =item[6] temp = attachment.split("[") #print temp for temp1 in temp: temp2 = temp1.split("u") for temp3 in temp2: temp4 = temp3.split("]") att = temp4[0] #print temp4[0] if source == 'googlecalendar': parts = email_from.split("Name:") for value in parts: email_from1 = value.split("email:") for some in email_from1: email_from2= some.split("\t") email_final = email_from2[0] if source == 'gmail': email_final = email_from if source == 'Brandeis Now': email_final = "Brandeis Now" message = "Null" subject = "Null" att = "Null" email_date = '2010-12-06 11:29:00' keywords1 = list(set(keywords)) count1 =0 count2=0 count3 =0 for child in keywords1: temp = "%" child1 = temp+child+temp sql_role = "SELECT count(role_id) FROM oneportal.mydata where mydata like '%s' and user_id = '%s'" %(child1,user_id) #print sql_role cursor.execute(sql_role) results=cursor.fetchall() for row in results: count = row[0] if count > 1: count1 = 1 if count == 1: count2 =1 data = child1 child2 = child1 if ((count2!=1) and (count1==1)): sql_insert = 'insert into email (role_id,user_id,message,date_email,from_email,datasource,subject,attachment) values ("2","%s","%s","%s","%s","%s","%s","%s")' %(user_id,message ,email_date,email_final,source,subject,att) #print sql_insert cursor.execute(sql_insert) db.commit() if (count2==1): sql_fetch = "select role_id from oneportal.mydata where mydata like '%s' and user_id = '%s'" %(data,user_id) cursor.execute(sql_fetch) results1=cursor.fetchall() for row1 in results1: role_id = row1[0] sql_insert = 'insert into email (role_id,user_id,message,date_email,from_email,datasource,subject,attachment) values ("%s","%s","%s","%s","%s","%s","%s","%s")' %(role_id,user_id,message ,email_date,email_final,source,subject ,att ) #print sql_insert cursor.execute(sql_insert) db.commit() if ((count2 ==0) and (count1 ==0)): sql_insert = 'insert into email (role_id,user_id,message,date_email,from_email,datasource,subject,attachment) values ("3","%s","%s","%s","%s","%s","%s","%s")'%(user_id,message,email_date,email_final,source,subject ,att ) #print sql_insert cursor.execute(sql_insert) db.commit()
#!c:/Python26/python.exe import cgi import header import cgitb import utility cgitb.enable() from db import database_connection print "Content-type: text/html; charset=iso-8859-1\n\n" customer_id = utility.getUserId(utility.getUserName()) def generate_deleteform(): db = database_connection() cursor = db.cursor() sql_role = "select a.role_id,a.role_name from roles a, mapping b where a.role_id = b.role_id and b.user_id = '%s'"%customer_id cursor.execute(sql_role) results=cursor.fetchall() #print header.printHeader() #print leftNav.printLeftNav() print header.printHeader() print '''<div class="left-side" style="width:745px;" >''' print '''<div class="formbox" align="center">''' print '''<form name="form_delete" action="delete_roles.py"><table border='1' class="formboxcontent"> <tr><td colspan="5"><b>Click on the respective Roles to Delete</b></td></tr> <tr><td colspan='1'> </td><td><b>Role Name</b></td></tr>''' for row in results: role_id = row[0] role_name = row[1]
def execute(self, args): """ A fair chunk of this stuff relies on stashy's wrapping of the STASH REST API, which is posted at https://developer.atlassian.com/static/rest/stash/2.12.1/stash-rest.html """ config = grapeConfig.grapeConfig() name = args["--user"] if not name: name = utility.getUserName() utility.printMsg("Logging onto %s" % args["--bitbucketURL"]) if args["--test"]: bitbucket = Atlassian.TestAtlassian(name) else: verify = True if args["--verifySSL"].lower() == "true" else False bitbucket = Atlassian.Atlassian(name, url=args["--bitbucketURL"], verify=verify) # default project (outer level project) project_name = args["--project"] # default repo (outer level repo) repo_name = args["--repo"] # determine source branch and target branch branch = args["--source"] if not branch: branch = git.currentBranch() # make sure we are in the outer level repo before we push wsDir = utility.workspaceDir() os.chdir(wsDir) #ensure branch is pushed utility.printMsg("Pushing %s to bitbucket..." % branch) git.push("origin %s" % branch) #target branch for outer level repo target_branch = args["--target"] if not target_branch: target_branch = config.getPublicBranchFor(branch) # load pull request from Bitbucket if it already exists wsRepo = bitbucket.project(project_name).repo(repo_name) existingOuterLevelRequest = getReposPullRequest(wsRepo, branch, target_branch, args) # determine pull request title title = args["--title"] if existingOuterLevelRequest is not None and not title: title = existingOuterLevelRequest.title() #determine pull request URL outerLevelURL = None if existingOuterLevelRequest: outerLevelURL = existingOuterLevelRequest.link() # determine pull request description descr = self.parseDescriptionArgs(args) if not descr and existingOuterLevelRequest: descr = existingOuterLevelRequest.description() # determine pull request reviewers reviewers = self.parseReviewerArgs(args) if reviewers is None and existingOuterLevelRequest is not None: reviewers = [r[0] for r in existingOuterLevelRequest.reviewers()] # if we're in append mode, only append what was asked for: if args["--append"] or args["--prepend"]: title = args["--title"] descr = self.parseDescriptionArgs(args) reviewers = self.parseReviewerArgs(args) ## Submodule Repos missing = utility.getModifiedInactiveSubmodules(target_branch, branch) if missing: utility.printMsg("The following submodules that you've modified are not currently present in your workspace.\n" "You should activate them using grape uv and then call grape review again. If you haven't modified " "these submodules, you may need to do a grape md to proceed.") utility.printMsg(','.join(missing)) return False pullRequestLinks = {} if not args["--norecurse"] and (args["--recurse"] or config.getboolean("workspace", "manageSubmodules")): modifiedSubmodules = git.getModifiedSubmodules(target_branch, branch) submoduleBranchMappings = config.getMapping("workspace", "submoduleTopicPrefixMappings") for submodule in modifiedSubmodules: if not submodule: continue # push branch os.chdir(submodule) utility.printMsg("Pushing %s to bitbucket..." % branch) git.push("origin %s" % branch) os.chdir(wsDir) repo = bitbucket.repoFromWorkspaceRepoPath(submodule, isSubmodule=True) # determine branch prefix prefix = branch.split('/')[0] sub_target_branch = submoduleBranchMappings[prefix] prevSubDescr = getReposPullRequestDescription(repo, branch, sub_target_branch, args) #amend the subproject pull request description with the link to the outer pull request subDescr = addLinkToDescription(descr, outerLevelURL, True) if args["--prepend"] or args["--append"]: subDescr = descr newRequest = postPullRequest(repo, title, branch, sub_target_branch, subDescr, reviewers, args) if newRequest: pullRequestLinks[newRequest.link()] = True else: # if a pull request could not be generated, just add a link to browse the branch pullRequestLinks["%s%s/browse?at=%s" % (bitbucket.rzbitbucketURL, repo.repo.url(), urllib.quote_plus("refs/heads/%s" % branch))] = False ## NESTED SUBPROJECT REPOS nestedProjects = grapeConfig.GrapeConfigParser.getAllModifiedNestedSubprojects(target_branch) nestedProjectPrefixes = grapeConfig.GrapeConfigParser.getAllModifiedNestedSubprojectPrefixes(target_branch) for proj, prefix in zip(nestedProjects, nestedProjectPrefixes): with utility.cd(prefix): git.push("origin %s" % branch) repo = bitbucket.repoFromWorkspaceRepoPath(proj, isSubmodule=False, isNested=True) newRequest = postPullRequest(repo, title, branch, target_branch,descr, reviewers, args) if newRequest: pullRequestLinks[newRequest.link()] = True else: # if a pull request could not be generated, just add a link to browse the branch pullRequestLinks["%s%s/browse?at=%s" % (bitbucket.rzbitbucketURL, repo.repo.url(), urllib.quote_plus("refs/heads/%s" % branch))] = False ## OUTER LEVEL REPO # load the repo level REST resource if not args["--subprojectsOnly"]: if not git.hasBranch(branch): utility.printMsg("Top level repository does not have a branch %s, not generating a Pull Request" % (branch)) return True if git.branchUpToDateWith(target_branch, branch): utility.printMsg("%s up to date with %s, not generating a Pull Request in Top Level repo" % (target_branch, branch)) return True repo_name = args["--repo"] repo = bitbucket.repoFromWorkspaceRepoPath(wsDir, topLevelRepo=repo_name, topLevelProject=project_name) utility.printMsg("Posting pull request to %s,%s" % (project_name, repo_name)) request = postPullRequest(repo, title, branch, target_branch, descr, reviewers, args) updatedDescription = request.description() for link in pullRequestLinks: updatedDescription = addLinkToDescription(updatedDescription, link, pullRequestLinks[link]) if updatedDescription != request.description(): request = postPullRequest(repo, title, branch, target_branch, updatedDescription, reviewers, args) utility.printMsg("Request generated/updated:\n\n%s" % request) return True
def run(): http_headers() customer_id = utility.getUserId(utility.getUserName()) #print 'id:%s'%customer_id print ''' <html>''' print header.printHeader() todo = datetime.date.today() print '''<head> <script type="text/javascript" src="/others/simpletreemenu.js"></script> <link rel="stylesheet" type="text/css" href="/others/jquery-ui-1.8.6.custom.css" /></link> <script type="text/javascript" src="/others/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/others/jquery-ui-1.8.6.custom.min.js"></script> <link rel="stylesheet" type="text/css" href="/others/simpletree.css" /></link> <link rel="stylesheet" type="text/css" href="/others/styles.css" /></link> </head> <title>SwiftMail</title> <body> <table align='center' width='800' height='500' border='1' class='pagecontent'> <tr><td colspan="2"> <div style="height: 135px;width: 1000px;;overflow:auto;"> <table class='pagecontent' border='0' width='800' align='center'> <tr width = "100%"><td colspan='2' width = "100%">''' print '''<h3 class="ui-widget-header">This is the to-do list for '%s'</h3>'''%todo print '''</td></tr>''' print '''<tr><td><b>From</b></td> <td><b>Subject</b></td></tr>''' sql_todo = "select message_id,message,date_email,from_email,datasource,subject,attachment from email where user_id = %s and date_email >= current_date()"%customer_id cursor.execute(sql_todo) results_todo=cursor.fetchall() for row in results_todo: message_id = row[0] message = row[1] date_email = row[2] from_email = row[3] datasource = row[4] subject =row[5] attachment = row[6] print '<tr><td>%s</td> '%from_email print '<td><a href=home.py?message_id=%s>%s</a></td></tr>'%(message_id,subject) print '''</table> </div></td> </tr>''' print '''<tr valign="top"> <td rowspan='2'> <script> $(function() { $( "#resizable2" ).resizable(); }); </script> <div id="resizable2" class="ui-widget-content"> <a href="javascript:ddtreemenu.flatten('treemenu1', 'expand')">Expand All</a> | <a href="javascript:ddtreemenu.flatten('treemenu1', 'contact')">Contract All</a> <div style="height:500px;width:206px;" style='table-layout:fixed'> <ul id="treemenu1" class="treeview">''' for row_root in results_root: print '<li>' role_id = row_root[0] role_id1 = row_root[0] role_name= row_root[1] print '<a href="home.py?role_id=%d">%s</a>'%(role_id,role_name) print '<ul>' sql_subroot = "select message_id,subject,from_email,date_email,datasource,attachment,role_id from email where user_id =%s and role_id = %s"%(customer_id,role_id) cursor.execute(sql_subroot) results_subroot=cursor.fetchall() if results_subroot: for row in results_subroot: message_id = row[0] message_id1 = row[0] subject = row[1] print '<li>' print '<a href="home.py?message_id=%d&role_id=%s">%s</a>'%(message_id,role_id,subject) print '</li>' else: message_id1 = 0 print '</ul>' print '<li>' print '''</ul></div> <script type="text/javascript"> ddtreemenu.createTree("treemenu1", false) </script> ''' print ''' <script> $(function() { $( "#resizable" ).resizable(); }); </script>''' print '''</div> </td> <td> <div id="resizable" class="ui-widget-content"; style="overflow:auto;"> <h3 class="ui-widget-header">Inbox</h3> <table align="left" border='1' style='table-layout:fixed' class='pagecontent' width='100%'> <tr><td><b>From</b></td><td><b>Subject</b></td><td><b>Date</b></td><td><b>DataSource</b></td><td><b>Attachment</b></td></tr> ''' form = cgi.FieldStorage() try: role_id=form["role_id"].value except: #print "Select a appropriate folder" role_id = role_id1 #print "role_id:%s"%role_id sql_subroot = "select message_id,subject,from_email,date_email,datasource,attachment,role_id from email where user_id ='%s' and role_id = '%s'"%(customer_id,role_id) #print sql_subroot cursor.execute(sql_subroot) results_subroot=cursor.fetchall() for row in results_subroot: message_id = row[0] subject = row[1] from_email = row[2] date_email = row[3] datasource = row[4] attachment = row[5] role_id = row[6] print '<tr><td>%s</td>'%from_email print ' <td>' print '<a href="home.py?message_id=%d&role_id=%s">%s</a>'%(message_id,role_id,subject) print '</td>' print '<td>%s</td>'%date_email print '<td>%s</td>'%datasource print '<td>%s</td></tr>'%attachment print '<form><input type="hidden" name="role_id" value="%s"></form>'%role_id print'''</table> </div> </td> </tr> <tr> <td valign='top'> <script> $(function() { $( "#resizable1" ).resizable(); }); </script> <div id="resizable1" class="ui-widget-content"> <h3 class="ui-widget-header">Full Email</h3>''' print '''<table border='0' style='table-layout:fixed' class='pagecontent' width='100%'>''' form = cgi.FieldStorage() try: message_id=form["message_id"].value except: message_id = message_id1 sql_message = 'select message,from_email,subject from email where message_id = %s'%(message_id) cursor.execute(sql_message) results_message=cursor.fetchall() for row in results_message: print '''<tr><td>''' from_email = row[1] print 'From : %s'%from_email print '''</td></tr>''' print '''<tr><td>''' subject = row[2] print 'Subject : %s'%subject print '''</td></tr>''' print '''<tr><td>''' print ' ' print '''</td></tr>''' print '''<tr><td>''' message = row[0] print '%s'%message print '''</td></tr>''' print '''</table></div>