Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def commit_post(self):
if config.vcs.commit():
config.uncommitted_changes = False
self.start_doc('Committed Changes')
self.output('<p>All changes to the Nitpick database have been committed</p>\n')
self.output('<a href="/%s">Go back to issue index</a>\n' % self.session_query());
self.end_doc()
else:
self.start_doc('Commit Error')
self.output('<p>Some/all changes to the Nitpick database failed to commit. Please check the console output</p>\n')
self.output('<a href="/%s">Go back to issue index</a>\n' % self.session_query());
self.end_doc()
@staticmethod
def _get_foreigns():
# Get the SVN external based foreign projects
foreign_list = subprocess.check_output("svn stat %s | grep '^X *%s' | awk '{print $2}'" %
(config.db_path, config.db_path), shell=True)
foreign_list = foreign_list.split('\n')
# Get the symlink based foreign projects
for file in os.listdir(config.db_path + 'foreign'):
path = config.db_path + 'foreign/' + file
if os.path.islink(path) and os.path.isdir(path):
foreign_list.append(path)
return foreign_list
web_cmd = subcmds.add_parser('web', help='Start nitpick web interface')
web_cmd.add_argument('--port', type=int, default=18080, help='Start the web server on the given port. Default 18080')
web_cmd.add_argument('--browser', help='Command to use to open web interface in browser')
web_cmd.add_argument('--noopen', action='store_true', help='Do not open a browser')
web_cmd.add_argument('--readonly', action='store_true', help='Present a readonly view suitable for a public dump')
web_cmd.set_defaults(func=cmd_web)
export_cmd = subcmds.add_parser('export', help='Export given bug')
export_cmd.add_argument('issue')
export_cmd.set_defaults(func=cmd_export)
import_cmd = subcmds.add_parser('import', help='Import all bugs in bug file')
import_cmd.add_argument('bugfile')
import_cmd.set_defaults(func=cmd_import)
if config.use_schedule:
schedule_cmd = subcmds.add_parser('sched', help='Display computed project schedule')
schedule_cmd.set_defaults(func=cmd_schedule)
args = parser.parse_args()
result = args.func(args)
if not result:
print "Command failed"
sys.exit(1)
else:
sys.exit(0)
def start_doc(self, title, onload_focus = None):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
if title != '':
title = title + ' - '
self.output(self.html_preamble(title + 'Nitpick', onload_focus))
if not config.readonly:
self.output('<div class="command_bar">\n')
self.output('<span class="command_button"><form method="post" action="/shutdown">')
self.output('<input value="Exit Web Interface" type="submit"></form></span>\n')
if config.uncommitted_changes and config.vcs.real:
self.output('<span class="command_button"><form method="post" action="/commit">')
if 'session' in self.request_args:
self.output('<input value="%s" name="session" type="hidden">\n' % self.request_args['session'])
self.output('<input value="Commit Changes" type="submit"></form></span>\n')
self.output('<span class="command_button"><form method="post" action="/revert">')
if 'session' in self.request_args:
self.output('<input value="%s" name="session" type="hidden">\n' % self.request_args['session'])
self.output('<input value="Revert Changes" type="submit"></form></span>\n')
self.output('</div>\n')
self.output('<br>\n')
filter_components = []
filter_fix_by = []
filter_severity = []
filter_priority = []
filter_state = config.issues['state'][:-1] # Don't show closed items by default
filter_resolution = []
filter_type = []
filter_owner = []
sort_field = 'State' # Sort by state by default
reverse_sort = False
# Load session defaults if we have some
load_settings = False
if 'session' in self.request_args and self.request_args['session'] in config.session_settings:
session_settings = config.session_settings[self.request_args['session']]
load_settings = True
def extract_show_field_arg(arg_name, arg_val):
if not load_settings:
if arg_name in self.request_args.keys():
arg_val = self.request_args[arg_name] == '1'
return arg_val
else:
return session_settings[arg_name]
if db.has_foreign():
show_repo = extract_show_field_arg('show_repo', show_repo)
show_ID = extract_show_field_arg('show_ID', show_ID)
show_type = extract_show_field_arg('show_type', show_type)
show_date = extract_show_field_arg('show_date', show_date)
show_severity = extract_show_field_arg('show_severity', show_severity)
def shutdown_post(self):
self.start_doc('Shutting Down')
self.output('<p>Nitpick web interface has exited</p>')
self.end_doc()
config.endweb = True
if issue_obj['Fix_By'] not in config.issues['fix_by']:
return 0
return config.issues['fix_by'].index(issue_obj['Fix_By'])
if sort_field == 'Severity':
if issue_obj['Severity'] not in config.issues['severity']:
return 0
return config.issues['severity'].index(issue_obj['Severity'])
if sort_field == 'Priority':
if issue_obj['Priority'] not in config.issues['priority']:
return 0
return config.issues['priority'].index(issue_obj['Priority'])
if sort_field == 'State':
if issue_obj['State'] not in config.issues['state']:
return 0
return config.issues['state'].index(issue_obj['State'])
if sort_field == 'Resolution':
if issue_obj['Resolution'] not in config.issues['resolution']:
return 0
return config.issues['resolution'].index(issue_obj['Resolution'])
if sort_field == 'Type':
if issue_obj['Type'] not in config.issues['type']:
return 0
return config.issues['type'].index(issue_obj['Type'])
if sort_field == 'Date':
return time.mktime(time.strptime(issue_obj['Date'], DATEFORMAT))
item_val = due_date.group(1)
item_date = due_date.group(2)
if item_val not in config.issues[key]:
if first_run:
config.issues[key].insert(0, item_val)
else:
config.issues[key].insert(-1, item_val)
if key == 'fix_by':
config.fix_by_dates[item_val] = item_date
if config.vcs == None:
for key in ['vcs']:
if key in conf.keys() and conf[key] in BACKENDS:
config.vcs = BACKENDS[conf[key]]
if config.project_name == 'Nitpick Project':
if 'project_name' in conf.keys():
config.project_name = conf['project_name']
if config.use_schedule == False and 'schedule' in conf.keys():
if conf['schedule'] == 'True':
config.use_schedule = True
else:
config.use_schedule = False
config.users = []
config.users_times = {}
for line in fileinput.input(repo_path + 'config/users'):
if line == '\n':
continue
work_units = re.search('(.*) \(([0-9.]+,[0-9.]+,[0-9.]+,[0-9.]+,[0-9.]+,[0-9.]+,[0-9.]+)\)', line)
'upload_filename' in self.request_args.keys():
comment['Attachment-filename'] = self.request_args['upload_filename']
comment['Attachment-filename'] = comment['Attachment-filename'].replace('/', '_')
comment['Attachment-filename'] = comment['Attachment-filename'].replace('\\', '_')
comment_filename = db.add_comment(self.request_args['issue'], comment)
self.start_doc('Comment %s added' % comment_filename)
self.output('<p>Successfully added the comment</p>\n')
self.output('<a href="/%s">Back to issue list</a> ' % self.session_query())
self.output('<a href="/issue/%s%s"> Back to issue %s</a>\n' % (self.request_args['issue'], self.session_query(),
self.request_args['issue'][:8]))
self.end_doc()
config.uncommitted_changes = True