def updateDetails(filename, full_path): index = string.find(full_path, 'documents') folder = full_path[index + 10:] if folder != '': data = os.stat(full_path + '/' + filename) else: folder = '/' data = os.stat(full_path + filename) date = time.strftime('%m/%d/%y', time.localtime(data[8])) # write detail info in HTML format lines = [] lines.append('<HTML><HEAD><TITLE>Data Item Details for: %s' % filename) lines.append('</TITLE></HEAD><BODY>') lines.append('<body background="/%s/icons/circ_bg.jpg">' % (db_name)) lines.append('<CENTER><B><FONT COLOR="#000099">Data Item Details Page') lines.append('</FONT></B><HR SIZE=1 NOSHADE WIDTH=100%>') lines.append('<TABLE border=0 align=center><TR><TD><B>') lines.append('Data Item Name:</B></TD><TD> %s <BR>' % (form['name'].value)) lines.append('<TR><TD><B>Date Entered:</B></TD><TD> %s <BR>' % (form['date'].value)) lines.append('<TR><TD><B>Filename:</B></TD><TD> %s <BR>' % (filename)) lines.append('<TR><TD><B>Version:</B></TD><TD> %s <BR>' % (form['version'].value)) lines.append('<TR><TD><B>Location:</B></TD><TD> %s <BR>' % (folder)) lines.append('<TR><TD><B>Description:</B></TD><TD> %s <BR>' % (form['description'].value)) lines.append('</TABLE>') lines.append('<HR><form method="POST" >') lines.append('<input type="button" value="Close Window" ') lines.append('onClick="return closerefresh()">') lines.append('</FORM></CENTER></BODY></HTML>') # if the filename has more than 1 period in it replace them with _ if string.count(filename, ".") > 1: filename = string.replace(filename, ".", "_") for line in lines: print line # create html file with detail info status, details = file_io.writeToFile('%s/%s.html' % (full_path, filename), lines) if status != 'success': file = open(fullpath + filename + '.html', 'w') file.close() file_io.writeToFile('%s/%s.html' % (full_path, filename), lines)
def create_declarations(self): status, declaration_template_lines = file_io.readFromFile(self.application_name + '.template') line_index = 0 for line in declaration_template_lines: field = string.split(line) if len(field) < 3: line_index = line_index + 1 continue if field[0][:len('tec_info')] == "tec_info": if field[1] == '=': if field[2] == "'{{{TEC_DB_NAME}}}'": declaration_template_lines[line_index] = field[0] + ' ' + field[1] + " '" + self.db_name + "'" line_index = line_index + 1 status, output = file_io.writeToFile('declarations.py', declaration_template_lines) if status != 'success': print output sys.exit(1)
def create_declarations(self): status, declaration_template_lines = file_io.readFromFile( '%s.template' % (self.db_name)) line_index = 0 for line in declaration_template_lines: field = string.split(line) if len(field) < 3: line_index = line_index + 1 continue if field[0][:8] == "pmt_info": if field[1] == '=': if field[2] == "'{{{DB_NAME}}}'": declaration_template_lines[line_index] = field[ 0] + ' ' + field[1] + " '" + self.db_name + "'" elif field[2] == "'{{{DOMAIN_NAME}}}'": declaration_template_lines[line_index] = field[ 0] + ' ' + field[1] + " '" + self.domain_name + "'" elif field[2] == "'{{{BROWSER_USERNAME}}}'": declaration_template_lines[ line_index] = field[0] + ' ' + field[ 1] + " '" + self.visitor_username + "'" elif field[2] == "'{{{BROWSER_PASSWORD}}}'": declaration_template_lines[ line_index] = field[0] + ' ' + field[ 1] + " '" + self.visitor_password + "'" elif field[2] == "'{{{HELP_URL}}}'": declaration_template_lines[line_index] = field[ 0] + ' ' + field[1] + " '" + self.help_url + "'" line_index = line_index + 1 status, output = file_io.writeToFile('declarations.py', declaration_template_lines)
def createDetails(filename, full_path, extracted=0): if extracted==1: itemname=filename date=time.strftime('%m/%d/%y',time.localtime(time.time())) file_name=filename version=form['version'].value index=string.find(full_path,'documents') location=full_path[index+10:] description='None' else: itemname=form['name'].value date=time.strftime('%m/%d/%y',time.localtime(time.time())) file_name=form['archive'].filename version=form['version'].value location=form['folder'].value description=form['description'].value if location=='': location='/' # write detail info in HTML format lines = [] lines.append('<HTML><HEAD><TITLE>Data Item Details for: %s</TITLE></HEAD><BODY>' % (filename)) lines.append('<body background="/%s/icons/circ_bg.jpg">' % (declarations.pmt_info['db_name'])) lines.append('<CENTER><B><FONT COLOR="#000099">Data Item Details Page</FONT></B><HR SIZE=1 NOSHADE WIDTH=100%>') lines.append('<TABLE border=0>') lines.append('<TR><TD><B>Data Item Name:</B></TD><TD> %s <BR>' % (itemname)) lines.append('<TR><TD><B>Date Entered:</B></TD><TD> %s <BR>' % date) lines.append('<TR><TD><B>Filename:</B></TD><TD> %s <BR>' % file_name) lines.append('<TR><TD><B>Version:</B></TD><TD> %s <BR>' % version) lines.append('<TR><TD><B>Location:</B></TD><TD> %s <BR>' % location) lines.append('<TR><TD><B>Description:</B></TD><TD> %s <BR>' % description) lines.append('</TABLE>') lines.append('</BODY></HTML>') # if the filename has more than 1 period in it replace them with _ if string.count(filename,".") > 1: filename = string.replace(filename,".","_") # create html file with detail info status, details = file_io.writeToFile(full_path + filename + '.html', lines) if status != 'success': html_msg = details upload_results(html_msg,'Could not generate html details file for %s' % (filename),form) sys.exit()
def delete_pwd_entry(passwd_filename, username): status, lines = file_io.readFromFile(passwd_filename) username_found = 0 for line_index in xrange(0, len(lines)): line_field = string.splitfields(lines[line_index], ':') if username == line_field[0]: del lines[line_index] username_found = 1 break if username_found: status, output = file_io.writeToFile(passwd_filename, lines) return ('success', 'username deleted') else: return ('error', 'username not found')
def add_pwd_entry(passwd_filename, crypt_salt, username, password): # salt can be at max 2 chars. crypt_salt = crypt_salt[:2] status, lines = file_io.readFromFile(passwd_filename) # if files does not exist if status == 'error': del lines lines = [] if lines != []: if username_in_passwd(passwd_filename, username): return ('error', 'username already in passwd file, can not add') # add new pw entry to lines lines.append(username + ':' + crypt.crypt(password, crypt_salt)) status, output = file_io.writeToFile(passwd_filename, lines) return (status, 'username added')
def modify_password(passwd_filename, crypt_salt, username, password): # salt can be at max 2 chars. crypt_salt = crypt_salt[:2] status, lines = file_io.readFromFile(passwd_filename) if status == 'error': return ('error', 0) for line_index in xrange(0, len(lines)): line_field = string.splitfields(lines[line_index], ':') if (username == line_field[0]): lines[line_index] = line_field[0] + ':' + crypt.crypt( password, crypt_salt) break status, output = file_io.writeToFile(passwd_filename, lines) # username/password not found return ('success', 0)
def doCsv(): status, table_data, db = pageInit("Export", formJS=0) if status != 'success': message = "Can not connect to database.\n" + status sql = "SELECT id, inv_prefix, outside_id, gist, source, inv_status, " sql = sql + "problem_description, problem_duplication, system_status, " sql = sql + "priority, category, originator, origination_date, assigned_to, " sql = sql + "analysis, analyst_signature, swm_analysis_signature, " sql = sql + "corrective_action, config_items_impacted, test_plan, " sql = sql + "test_results, swm_completion_signature, " sql = sql + "test_completion_signature, cm_completion_signature, " sql = sql + "qa_completion_signature from inventory ORDER by inv_prefix, int4(id)" queryResult = pmt_utils.executeSQL(db, sql) if queryResult["status"] != 'success': message = "Query failed.\n" + dbResult['message'] result = queryResult['result'] print '<a href="/%s/html/%s">' % (db_name, 'inventory.csv') print 'Inventory File ' print '(Right Click and select "Save Link As" to download)</a>' print '<BR><BR><B>The Comma Separated Values file contains the following' print 'fields for each record:</B>' print '<TABLE BORDER>' print '<TR><TD>Inventory Id</TD><TD>Prefix</TD><TD>Outside Id</TD>' print '<TD>Gist</TD><TD>Source</TD><TD>Status</TD>' print '<TD>Problem Description</TD><TD>Problem Duplication</TD>' print '<TD>System Status</TD><TD>Priority</TD><TD>Category</TD>' print '<TD>Originator</TD><TD>Origination Date</TD><TD>Assigned To</TD>' print '<TD>Analysis</TD><TD>Corrective Action</TD>' print '<TD>Configuration Items Impacted</TD><TD>Test Plan</TD>' print '<TD>Test Results</TD><TD>Completion Status</TD></TR></TABLE>' print 'NOTE: Commas in fields have been changed to whitespace' output_lines = [] for i in xrange(0, len(result)): inv_completed = 'Open' if string.strip(result[i]['inv_status']) == 'Fixed (complete)': if string.strip(result[i]['analyst_signature']) != '' and \ string.strip(result[i]['swm_analysis_signature'])!='' and \ string.strip(result[i]['swm_completion_signature'])!='' and \ string.strip(result[i]['test_completion_signature'])!='' and \ string.strip(result[i]['cm_completion_signature'])!='' and \ string.strip(result[i]['qa_completion_signature'])!='': inv_completed = 'Closed' txt = string.replace(result[i]['inv_prefix'], ',', '') + ',' txt = txt + string.replace(result[i]['id'], ',', '') + ',' txt = txt + string.replace(result[i]['outside_id'], ',', '') + ',' txt = txt + string.replace(result[i]['gist'], ',', '') + ',' txt = txt + string.replace(result[i]['source'], ',', '') + ',' txt = txt + string.replace(result[i]['inv_status'], ',', '') + ',' txt = txt + string.replace(result[i]['problem_description'], ',', '') + ',' txt = txt + string.replace(result[i]['problem_duplication'], ',', '') + ',' txt = txt + string.replace(result[i]['system_status'], ',', '') + ',' txt = txt + string.replace(result[i]['priority'], ',', '') + ',' txt = txt + string.replace(result[i]['category'], ',', '') + ',' txt = txt + string.replace(result[i]['originator'], ',', '') + ',' txt = txt + string.replace(result[i]['origination_date'], ',', '') + ',' txt = txt + string.replace(result[i]['assigned_to'], ',', '') + ',' txt = txt + string.replace(result[i]['analysis'], ',', '') + ',' txt = txt + string.replace(result[i]['corrective_action'], ',', '') + ',' txt = txt + string.replace(result[i]['config_items_impacted'], ',', '') + ',' txt = txt + string.replace(result[i]['test_plan'], ',', '') + ',' txt = txt + string.replace(result[i]['test_results'], ',', '') + ',' txt = txt + inv_completed txt = string.replace(txt, '\r\n', ' ') txt = string.replace(txt, '\n', ' ') output_lines.append(txt) filename = '/home/%s/html/inventory.csv' % db_name file_io.writeToFile(filename, output_lines) queryFunctionButtons(0, 1, '/%s/html/sprsum.html' % (db_name)) pmt_utils.textbox(None, 'key_id', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') pageEnd(table_data, db)
def doCsv(): # Setup the javascript and html, connect to the db subHeading = 'Address Book (Palm Desktop Import File)' status, table_data, db = pageInit(subHeading, formJS=0) if status != 'success': message = "Couldn't connect to db.\n%s" % (status) exit(message) # Get project member contact info sql = "SELECT first_name, last_name, email, company_name, " sql = sql + "address_line_1, address_line_2, city, state, zip, " sql = sql + "phone_number_voice, phone_extension, " sql = sql + "cell_phone_number, phone_number_fax " sql = sql + "from project_members ORDER by last_name, first_name" queryResult = pmt_utils.executeSQL(db, sql) if queryResult["status"] != 'success': message = "Query failed.\n" + dbResult['message'] exit(message) result = queryResult['result'] # Display a link to the file and a listing of the data itself url = '/%s/html/%s' % (urllib.quote(db_name), 'address_book.dat') print '<BR><BR><a href="%s">' % url print 'Palm Desktop Address Book Import File ' print '(Right Click Here and select ' print '"Save Link As" to download)</a>' print '<BR><BR><B>You should configure Palm Desktop Tools ' print 'to import the Address Book with a comma used as the ' print 'field deliminter and with the following order of the ' print 'fields for each address entry:</B>' print '<TABLE BORDER>' print '<TR><TD>First Name</TD><TD>Last Name</TD>' print '<TD>Company Name</TD><TD>Address</TD><TD>City</TD>' print '<TD>State</TD><TD>Zip Code</TD><TD>Work</TD>' print '<TD>Fax</TD><TD>Mobile</TD><TD>E-Mail</TD></TR></TABLE>' print '<BR><B>The contents of this Address Book ' print 'Import file follows:</B>' print '<PRE>' output_lines = [] for i in xrange(0, len(result)): if string.strip(result[i]['phone_extension']) != '': ext = ' x' + result[i]['phone_extension'] else: ext = '' if string.strip(result[i]['address_line_1']) != '': address = result[i]['address_line_1'] if string.strip(result[i]['address_line_2']) != '': address = address + ' ' + result[i]['address_line_2'] else: address = '' outline = result[i]['first_name'] + ',' outline = outline + result[i]['last_name'] + ',' outline = outline + result[i]['company_name'] + ',' outline = outline + address + ',' outline = outline + result[i]['city'] + ',' outline = outline + result[i]['state'] + ',' outline = outline + result[i]['zip'] + ',' outline = outline + result[i]['phone_number_voice'] + ext + ',' outline = outline + result[i]['phone_number_fax'] + ',' outline = outline + result[i]['cell_phone_number'] + ',' outline = outline + result[i]['email'] print outline output_lines.append(outline) # Write the contact data to a file output_filename = '/home/%s/html/address_book.dat' % db_name file_io.writeToFile(output_filename, output_lines) print '</PRE>' # Add buttons, hidden html form data, and company info queryFunctionButtons(0, '/%s/html/contactsum.html' % (db_name)) pmt_utils.textbox(None, 'key_id', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') pageEnd(table_data, db)
msg = '%s using NOW keyword' % msg data.append(msg) date = time_pkg.current_time_MM_DD_YYYY() data.append('The date when CVS export occurred was %s' % (date)) data.append('') data.append('Institute for Software Research (ISR), Inc.') data.append('1000 Technology Drive') data.append('Suite 3210') data.append('Fairmont, WV 26554') data.append('Voice: 304-368-9300') data.append('FAX: 304-534-4106') data.append('E-mail: [email protected]') outFilename = encapsulated_file_location + '/MODULE_VERSION' status, details = file_io.writeToFile(outFilename, data) outFilename = web_cvs_dir + '/' + form['module_name'].value result = cvs_utils.cvs_export_encapsulate_distribution( form['module_name'].value, form['encapsulation_type'].value, outFilename, 'now', None, 1, module_path) status, export_output, tar_ball_contents = result if status != 'success': export_output = '<BR><FONT SIZE="3" COLOR=RED>%s<BR>' % export_output export_output = '%sCan not find module specified.' % export_output export_output = '%s Export aborted!' % export_output export_output = '%s</FONT></TD></TR></TABLE><BR>' % export_output elif string.strip(form['release'].value) != '':
data.append( 'User exported current version of all files in the module using NOW keyword' ) data.append('The date when CVS export occurred was %s' % (time_pkg.current_time_MM_DD_YYYY())) data.append('') data.append('Institute for Software Research (ISR), Inc.') data.append('1000 Technology Drive') data.append('Suite 3210') data.append('Fairmont, WV 26554') data.append('Voice: 304-368-9300') data.append('FAX: 304-534-4106') data.append('E-mail: [email protected]') status, details = file_io.writeToFile( encapsulated_file_location + '/MODULE_VERSION', data) status, export_output, tar_ball_contents = cvs_utils.cvs_export_encapsulate_distribution( form['module_name'].value, form['encapsulation_type'].value, web_tree_cvs_exports_dir + '/' + form['module_name'].value, 'now', None, 0) if status != 'success': export_output = """<BR><BR><FONT SIZE=2 COLOR=RED>Can not find module specified. Export aborted!</FONT> </TD></TR> </TABLE><BR>""" elif string.strip(form['release'].value) != '': data = [] data.append('ISR CVS Export for the module :%s' %