def create_project(cur, name, definition):
	inputs = (name, definition)
	cur.execute(""" SELECT COUNT(*) FROM 
				 list_of_projects WHERE Project = ? """, (name, ))
	result = cur.fetchone()
	if result[0]:
		raise errors.myError(name+' already exists!\n')
	else:
		cur.execute("INSERT INTO list_of_projects VALUES(?, ?)", inputs)
Beispiel #2
0
			project_description = raw_input('>> ')
			scripts.creating_project_prompt(project_name)
			createProject.create_project(cur, project_name, project_description)
		elif user_input == 'select' or user_input == 'Select':
			while True:
				scripts.project_list_prompt()
				selectProject.display_existing_projects(cur)
				for row in cur:
					print "--> ", row[0]
				scripts.select_project_prompt()
				project_select = raw_input('>> ')
				if project_select == 'Cancel' or project_select == 'cancel':
					break
				else:
					selectProject.check_existing_projects(cur, project_select)
					scripts.select_menu()
					entry_choice = raw_input('>> ')
					if entry_choice == 'View' or entry_choice == 'view':
						print 'Viewing entry'
					elif entry_choice == 'New' or entry_choice == 'new':
						timerFunctions.timer_function()
						print 'making new entry'
					elif entry_choice == 'Cancel' or entry_choice == 'cancel':
						break
					else:
						raise errors.myError('invalid entry\n')
		else:
			raise errors.myError('invalid entry\n')
	except errors.myError as err:
		print ('Error: '+err.value)
def check_existing_projects(cur, project_select):
	cur.execute(""" SELECT COUNT(*) FROM 
				list_of_projects WHERE Project = ? """, (project_select, ))
	result = cur.fetchone()
	if not result[0]:
		raise errors.myError(project_select+' does not exist!')