def delete_question(): if (not has_access(request.remote_addr, Admin, overrideTime = True)): return redirect("/login/Admin/@2Fcreate@2F" + course + "@2F" + semester) update(request.remote_addr) remove_question(request.form.get('id')) return "Question deleted."
def edit_survey(course, semester): if (not has_access(request.remote_addr, Admin)): return redirect("/login/Admin/@2Fcreate@2F" + course + "@2F" + semester) update(request.remote_addr) saved_questions = read_all_questions() return render_template("edit_survey.html", course = course, semester = semester, saved_questions = saved_questions)
def publish_survey(): if (not has_access(request.remote_addr, Admin, overrideTime = True)): return redirect("/login/Admin/@2Fcreate@2F" + request.form['course'] + "@2F" + request.form['semester']) update(request.remote_addr) response = save_survey(request.form) return response
def staffHome(): if (not has_access(request.remote_addr, Staff)): return redirect("/login/Staff/@2FstaffHome") update(request.remote_addr) user = get_user(request.remote_addr) all_review_surveys = get_surveys(state = 0) review_surveys = [] for survey in all_review_surveys: if (user.is_enrolled_in(survey.course)): review_surveys.append(survey) all_active_surveys = get_surveys(state = 1) active_surveys = [] for survey in all_active_surveys: if (user.is_enrolled_in(survey.course)): active_surveys.append(survey) all_closed_surveys = get_surveys(state = 2) closed_surveys = [] for survey in all_closed_surveys: if (user.is_enrolled_in(survey.course)): closed_surveys.append(survey) root = request.url_root return render_template("staffHome.html", review_surveys = review_surveys, active_surveys = active_surveys, closed_surveys = closed_surveys, root = root)
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ # table_index = 0 # for row in table: # if id_[0] == row[0]: # for i in range(len(row)): # user_input = ''.join(ui.get_inputs([f"({row[i]}) Write new record or press 'Enter' to continue "], "")) # if user_input == "": # continue # else: # row[i] = user_input # table[table_index] = row # table_index += 1 # data_manager.write_table_to_file("sales/sales.csv", table) common.update("sales/sales.csv", table, id_) show_table(table) return table
def review_saved_questions(): if (not has_access(request.remote_addr, Admin)): return redirect("/login/Admin/@2Freview_questions") update(request.remote_addr) saved_questions = read_all_questions() return render_template("viewQuestions.html", saved_questions = saved_questions)
def closeSurvey(course, semester): if (not has_access(request.remote_addr, Staff)): return redirect("/login/Staff/@2Fclose_survey@2F" + course + "@2F" + semester) update(request.remote_addr) survey = Survey() survey.load_course_from_db(DATABASE_FILENAME, course, semester) db_execute(DATABASE_FILENAME, 'UPDATE SURVEYS SET STATE = "2" WHERE ID = ' + str(survey.id)) return redirect('/login')
def login(role = None, page = None): if page == None: if (has_access(request.remote_addr, Admin)): return redirect("/adminHome") if (has_access(request.remote_addr, Student)): return redirect("/studentHome") if (has_access(request.remote_addr, Staff)): return redirect("/staffHome") update(request.remote_addr) return login_page(request, role, page)
def viewResults(course, semester): if (not (has_access(request.remote_addr, Student) or has_access(request.remote_addr, Staff))): return redirect("/login/Staff/@2Fresults@2F"+course+"@2F"+semester) update(request.remote_addr) survey = Survey() survey = survey.load_course_from_db(DATABASE_FILENAME, course, semester) responses = get_all_survey_responses(survey) return render_template('metrics.html', survey = survey, responses = responses)
def save_question(): if (not has_access(request.remote_addr, Admin, overrideTime = True)): return redirect("/login/Admin/@2Fcreate") update(request.remote_addr) return str(write_question({'questionText': request.form.get('questionText'), 'options': json.loads(request.form.get('options')), 'multi': request.form.get('multi'), 'text': request.form.get('text'), 'mandatory': request.form.get('mandatory'), 'saved_id': request.form.get('saved_id')}))
def metrics(course, semester): if (not has_access(request.remote_addr, Admin)): return redirect("/login/Admin/@2Fmetrics@2F"+course+"@2F"+semester) update(request.remote_addr) survey = Survey() survey = survey.load_course_from_db(DATABASE_FILENAME, course, semester) responses = get_all_survey_responses(survey) return render_template('metrics.html', survey = survey, responses = responses)
def studentResults(): if (not has_access(request.remote_addr, Student)): return redirect("/login/Student/@2FstudentResults") update(request.remote_addr) user = get_user(request.remote_addr) all_closed_surveys = get_surveys(state = 2) closed_surveys = [] for survey in all_closed_surveys: if user.is_enrolled_in(survey.course): closed_surveys.append(survey) return render_template("studentResults.html", closed_surveys = closed_surveys)
def studentHome(): if (not has_access(request.remote_addr, Student)): return redirect("/login/Student/@2FstudentHome") update(request.remote_addr) user = get_user(request.remote_addr) all_active_surveys = get_surveys(state = 1) active_surveys = [] for survey in all_active_surveys: if user.is_enrolled_in(survey.course) and not user.has_responded_to(DATABASE_FILENAME, survey): active_surveys.append(survey) return render_template("studentHome.html", active_surveys = active_surveys)
def edit_answer_post(answer_id): if len(request.form["answer"]) < 10: answer = common.get_answer(answer_id) question = common.get_question(answer["question_id"]) return render_template("answer.html", question=question, answer=answer, mode="Edit", error="10 char") answer = common.get_answer(answer_id) answer["message"] = request.form["answer"] common.update("answer", answer_id, "message", answer["message"]) return redirect("/question/{}".format(answer["question_id"]), code=302)
def handle(self): if self.phase_end(): game.server_call("next_phase") else: passed_milliseconds = min(self.clock.tick(), 500) # handle redraws and other actions that occur each frame self.actions(passed_milliseconds) for player in game.players: player.handle_movement(passed_milliseconds) player.draw_cursor() self.time_left -= passed_milliseconds * 0.001 game.print_time() common.update()
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table: list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ common.update("store/games.csv", table, id_) show_table(table) return table
def start_module(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ # your code while True: title = "Inventory module" exit_message = "Exit to main" options = ["Show table", "Add item", "Remove item", "Update item", "Available items", "Avg durability by manufacturer"] ui.print_menu(title, options, exit_message) inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/inventory/inventory.csv" table = data_manager.get_table_from_file(file_name) title_list = ['id', 'title', 'manufacturer', 'purchase_year', 'durability'] questions_asked = ['title: ', 'manufacturer: ', 'purchase_year: ', 'durability: '] unique_id = '' if option == "1": common.show_table(table, title_list) elif option == "2": common.add(table, questions_asked) elif option == "3": common.remove(table, unique_id, title_list) elif option == "4": common.update(table, unique_id, title_list) elif option == "5": get_available_items(table, year) elif option == "6": get_average_durability_by_manufacturers(table) elif option == "0": break return table
def __init__(self, next_phase): State.__init__(self) announce_text = getattr(game.field.map, next_phase.phase_name + "_phase_text") self.make_announce_surface(*announce_text) common.blit( self.announce_surface, divide( subtract(common.screen.get_size(), self.announce_surface.get_size()), 2), ) common.update() self.start_time = pygame.time.get_ticks() self.next_phase = next_phase
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ # your code file_name = "hr/persons.csv" new_data_properties = ["Name", "Birth year"] common.update(table, id_, new_data_properties, file_name) return table
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ # your code file_name = "sales/sales.csv" new_data_properties = ["Title", "Price (USD)", "Month", "Day", "Year"] common.update(table, id_, new_data_properties, file_name) return table
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ # your code file_name = "accounting/items.csv" new_data_properties = ["Month", "Day", "Year", "Type", "Amount"] common.update(table, id_, new_data_properties, file_name) return table
def update_status( self, status, dataset_id='All', msg='' ): ''' Update the data transfer status for this dataset in the database ''' try: log.debug( 'Setting status "%s" for dataset "%s" of sample "%s"' % ( status, str( dataset_id ), str( self.sample_id) ) ) sample_dataset_ids = [] if dataset_id == 'All': for dataset in self.dataset_files: sample_dataset_ids.append( api.encode_id( self.config_id_secret, dataset[ 'dataset_id' ] ) ) else: sample_dataset_ids.append( api.encode_id( self.config_id_secret, dataset_id ) ) # update the transfer status data = {} data[ 'update_type' ] = SamplesAPIController.update_types.SAMPLE_DATASET[0] data[ 'sample_dataset_ids' ] = sample_dataset_ids data[ 'new_status' ] = status data[ 'error_msg' ] = msg url = "http://%s/api/samples/%s" % ( self.galaxy_host, api.encode_id( self.config_id_secret, self.sample_id ) ) log.debug( str( ( self.api_key, url, data))) retval = api.update( self.api_key, url, data, return_formatted=False ) log.debug( str( retval ) ) except urllib2.URLError, e: log.debug( 'ERROR( sample_dataset_transfer_status ( %s ) ): %s' % ( url, str( e ) ) ) log.error( traceback.format_exc() )
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ # your code file_name = "inventory/inventory.csv" new_data_properties = ["Name", "Manufacturer", "Year of purchase", "Durability"] common.update(table, id_, new_data_properties, file_name) return table
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ # your code file_name = "crm/customers.csv" new_data_properties = ["Name", "E-mail", "Subscribed to newsletter"] common.update(table, id_, new_data_properties, file_name) return table
def start_module(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ while True: title = "Sales manager" exit_message = "(0) Back to main menu" list_options = [ "(1) Show table", "(2) Add", "(3) Remove", "(4) Update", "(5) Cheapo game", "(6) Items sold between", "(7) Get title by ID", "(8) Get item ID sold last" ] ui.print_menu(title, list_options, exit_message) inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] file_name = "sales/sales.csv" title_list = ["id", "title", "price", "month", "day", "year"] table = data_manager.get_table_from_file(file_name) list_titles = ["month: ", "day: ", "year: ", "type: ", "amount: "] id_ = '' if option == "1": common.show_table(table, title_list) elif option == "2": common.add(table, list_titles, file_name) elif option == "3": common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name) elif option == "4": common.update(table, ui.get_inputs(["ID: "], "")[0], file_name) elif option == "5": get_lowest_price_item_id(table) elif option == "6": get_items_sold_between(table, month_from, day_from, year_from, month_to, day_to, year_to) elif option == "7": get_title_by_id_from_table(table, ui.get_inputs(["ID: "], "")[0]) elif option == "8": get_item_id_sold_last(table) elif option == "0": break
def commit_review(): if (not has_access(request.remote_addr, Staff, overrideTime = True)): return redirect("/login/Staff/@2Fcommit_review") update(request.remote_addr) survey = Survey() survey.load_course_from_db(DATABASE_FILENAME, request.form.get('course'), request.form.get('semester')) survey.questions = [] for questionId in json.loads(request.form.get('ids')): question = Question() question.load_from_db(DATABASE_FILENAME, questionId) survey.questions.append(question) survey.update_db(DATABASE_FILENAME) return "Success"
def start_module(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ # you code while True: title = "Accounting module" exit_message = "Exit to main" options = [ "Show table", "Add item", "Remove item", "Update item", "Highest profit year", "Avg profit by item" ] ui.print_menu(title, options, exit_message) inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/accounting/items.csv" table = data_manager.get_table_from_file(file_name) title_list = ['id', 'month', 'day', 'year', 'type', 'amount'] questions_asked = ['month: ', 'day: ', 'year: ', 'type: ', 'amount: '] unique_id = '' if option == "1": common.show_table(table, title_list) elif option == "2": common.add(table, questions_asked) elif option == "3": common.remove(table, unique_id, title_list) elif option == "4": common.update(table, unique_id, title_list) elif option == "5": which_year_max(table) elif option == "6": avg_amount(table, year) elif option == "0": break
def start_module(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ # your code while True: title = "Sales module" exit_message = "Exit to main" options = [ "Show table", "Add item", "Remove item", "Update item", "Lowest priced item", "Items sold by date" ] ui.print_menu(title, options, exit_message) inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/sales/sales.csv" table = data_manager.get_table_from_file(file_name) title_list = ['id', 'title', 'price', 'month', 'day', 'year'] questions_asked = ["title: ", "price: ", "month: ", "day: ", "year: "] unique_id = '' if option == "1": common.show_table(table, title_list) elif option == "2": common.add(table, questions_asked) elif option == "3": common.remove(table, unique_id, title_list) elif option == "4": common.update(table, unique_id, title_list) elif option == "5": get_lowest_price_item_id(table) elif option == "6": get_items_sold_between(table, month_from, day_from, year_from, month_to, day_to, year_to) elif option == "0": break
def start_module(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ # your code while True: title = "Human resources module" exit_message = "Exit to main" options = [ "Show table", "Add item", "Remove item", "Update item", "Oldest person", "Avg aged person" ] ui.print_menu(title, options, exit_message) inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/hr/persons.csv" table = data_manager.get_table_from_file(file_name) title_list = ['id', 'name', 'birth_year'] questions_asked = ['name: ', 'birth_year: '] unique_id = '' if option == "1": common.show_table(table, title_list) elif option == "2": common.add(table, questions_asked) elif option == "3": common.remove(table, unique_id, title_list) elif option == "4": common.update(table, unique_id, title_list) elif option == "5": get_oldest_person(table) elif option == "6": get_persons_closest_to_average(table) elif option == "0": break
def start_module(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ # your code while True: title = "Customer Relationship Management module" exit_message = "Exit to main" options = [ "Show table", "Add item", "Remove item", "Update item", "Longest name", "Subscription" ] ui.print_menu(title, options, exit_message) inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] file_name = "/home/frojim/Documents/CC/lightweight-erp-python-extremely-random-programmers/crm/customers.csv" table = data_manager.get_table_from_file(file_name) title_list = ['id', 'name', 'email', 'subscribed'] questions_asked = ['name: ', 'email: ', 'subscribed: '] unique_id = '' if option == "1": common.show_table(table, title_list) elif option == "2": common.add(table, questions_asked) elif option == "3": common.remove(table, unique_id, title_list) elif option == "4": common.update(table, unique_id, title_list) elif option == "5": get_longest_name_id(table) elif option == "6": get_subscribed_emails(table) elif option == "0": break
def start_module(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ while True: title = "CRM manager" exit_message = "(0) Back to main menu" list_options = [ "(1) Show table", "(2) Add", "(3) Remove", "(4) Update", "(5) ID of longest name", "(6) subscribers", "(7) Customer name by ID" ] ui.print_menu(title, list_options, exit_message) inputs = ui.get_inputs(["Please enter a number: "], "") option = inputs[0] file_name = "crm/customers.csv" title_list = ["id", "name", "email", "subscribed"] table = data_manager.get_table_from_file(file_name) list_titles = ["name: ", "email: ", "subscriber (0/1): "] id_ = '' if option == "1": common.show_table(table, title_list) elif option == "2": common.add(table, list_titles, file_name) elif option == "3": common.remove(table, ui.get_inputs(["ID: "], "")[0], file_name) elif option == "4": common.update(table, ui.get_inputs(["ID: "], "")[0], file_name) elif option == "5": get_longest_name_id(table) elif option == "6": get_subscribed_emails(table) elif option == "7": get_name_by_id_from_table(table, ui.get_inputs(["ID: "], "")[0]) elif option == "0": break
def update_request( api_key, request_id ): encoded_request_id = api.encode_id( config.get( "app:main", "id_secret" ), request_id ) data = dict( update_type=RequestsAPIController.update_types.REQUEST ) url = "http://%s:%s/api/requests/%s" % ( config.get(http_server_section, "host"), config.get(http_server_section, "port"), encoded_request_id ) log.debug( 'Updating request %i' % request_id ) try: retval = api.update( api_key, url, data, return_formatted=False ) log.debug( str( retval ) ) except Exception, e: log.debug( 'ERROR(update_request (%s)): %s' % ( str((self.api_key, url, data)), str(e) ) )
def input_data(root_path): for fp in com.all_files(root_path, EXCL_LIST): cur = com.file_stat(fp); db = com.select(fp); if cur['size'] < 100000000: # 100MB continue if db == None: h = com.hash(fp) if h != None : com.input(cur['path'], cur['size'], cur['date'], com.hash(fp)) print('등록',fp) continue # DB에 이미 등록되어 있고, 크기 및 날짜가 같다면 다음 if com.is_same_stat(cur, db) : print('이미 등록',fp) continue print('갱신',fp) com.update(cur['path'], cur['size'], cur['date'], com.hash(fp))
def main(action, file, format, repo, verbose=0, name=False, test=False): package_name = common.git_check(repo) sys.path.append(repo) try: __import__(package_name) except ImportError as e: if verbose >= 1: print str(e) print "Failed to import: %s (%s)" % (package_name, e) if verbose >= 1: flags = common.extract_flags(repo, package_name, verbose) else: flags = common.extract_flags(repo, package_name) print "%s flags imported from package %s." % (len(flags), str(package_name)) if action == "update": common.update(file, flags, True, verbose) return if format == "names": if verbose >= 1: common.write_flags(file, flags, True, verbose) else: common.write_flags(file, flags, True) if format == "docbook": groups = common.populate_groups(file) print "%s groups" % len(groups) if verbose >= 1: common.write_docbook('.', flags, groups, package_name, verbose) else: common.write_docbook('.', flags, groups, package_name) sys.exit(0)
#!/usr/bin/env python import os, sys, traceback sys.path.insert( 0, os.path.dirname( __file__ ) ) from common import display from common import submit from common import update try: data = {} data[ 'update_type' ] = 'sample_dataset_transfer_status' data[ 'sample_dataset_ids' ] = sys.argv[3].split(',') data[ 'new_status' ] = sys.argv[4] except IndexError: print 'usage: %s key url sample_dataset_ids new_state [error msg]' % os.path.basename( sys.argv[0] ) sys.exit( 1 ) try: data[ 'error_msg' ] = sys.argv[5] except IndexError: data[ 'error_msg' ] = '' print data update( sys.argv[1], sys.argv[2], data, return_formatted=True )
#!/usr/bin/env python """ Generic PUT/update script usage: create.py key url [key=value ...] """ import sys from common import update data = {} for k, v in [kwarg.split("=", 1) for kwarg in sys.argv[3:]]: data[k] = v update(sys.argv[1], sys.argv[2], data)