def test_command_with_difficult_params(self): program = CommandLine() program.parse_command_line('add "param_param_123_1"') state = program.get_state() self.assertEqual(state['state'], 'command with params') self.assertEqual(state['command'], 'add') self.assertEqual(state['command_params'], 'param_param_123_1')
def test_command_with_params(self): program = CommandLine() program.parse_command_line('add param') state = program.get_state() self.assertEqual(state['state'], 'command with params') self.assertEqual(state['command'], 'add') self.assertEqual(state['command_params'], 'param')
class Test_test_command_line(unittest.TestCase): # Mock the print call in CommandLine() @patch('command_line.print', create=True) # Note added , print_ to mock print() def test_command_line_no_jobs_file_specified(self, print_): sys.argv = ['ScriptedJsonEditor'] with patch('builtins.input', return_value=''): self.CLo = CommandLine() jobsFile = self.CLo.get_jobs_file() assert jobsFile is None, jobsFile ''' No job file in command line now calls the GUI @patch('command_line.print', create=True) # Mock the print call in CommandLine() def test_command_line_jobs_file_entered(self, print_): # Note added , print_ to mock print() """ Test console entry of the job file name """ sys.argv = ['ScriptedJsonEditor'] with patch('builtins.input', return_value='JsonEditorJobs.json'): self.CLo = CommandLine() jobsFile = self.CLo.get_jobs_file() assert jobsFile == 'JsonEditorJobs.json', jobsFile ''' def test_command_line(self): sys.argv = ['ScriptedJsonEditor', 'JsonEditorJobs.json'] self.CLo = CommandLine() jobsFile = self.CLo.get_jobs_file() assert jobsFile == 'JsonEditorJobs.json', jobsFile
def test_command_with_params_and_key_optional_params_without_params(self): program = CommandLine() program.parse_command_line('add param -n') state = program.get_state() self.assertEqual(state['state'], 'command with params and key') self.assertEqual(state['command'], 'add') self.assertEqual(state['command_params'], 'param') self.assertEqual(state['key'], '-n')
def test_command_with_params_and_key_with_difficult_params(self): program = CommandLine() program.parse_command_line('add param -a "key_param_123_1"') state = program.get_state() self.assertEqual(state['state'], 'command with params and key with params') self.assertEqual(state['command'], 'add') self.assertEqual(state['command_params'], 'param') self.assertEqual(state['key'], '-a') self.assertEqual(state['key_params'], 'key_param_123_1')
def main(versionStr=''): """ Main """ _clo = CommandLine(versionStr) jobs_file_name = _clo.get_jobs_file() playerID = _clo.get_playerID() rF2root = _clo.get_rF2root() if jobs_file_name is None: import GUI # if imported "normally" there is a deadly embrace # when GUI imports this file. # No jobs file in command line GUI.Main(playerID, rF2root, goCommand=True) return 0, '' return execute_job_file(playerID, rF2root, jobs_file_name)
def run(args): file_manager, cpu_manager = load_managers(args) command_line_tools = CommandLine(file_manager, cpu_manager, args.sample_name) if args.phase: step = Phase(file_manager, cpu_manager, command_line_tools) elif args.assemble: step = Assemble(file_manager, cpu_manager, command_line_tools) elif args.detect: step = DetectVariants(file_manager, cpu_manager, command_line_tools) else: sys.exit("Select phase, assemble, detect, stats or report") step.load_args(args) return step()
def show(self): value = CommandLine.get_next() if value: return value print '\n', if self.query: print self.query+':' i = 0 for item in self.items: i += 1 print '\t' + str(i) + ' - ' + item.text value = None while value == None or not (value.isdigit() and 0 < int(value) and int(value) < self.items.count): value = raw_input("Please select an option: ") return self.items[int(value)-1].value
def cli(): command_line = CommandLine() if command_line.process(request): return jsonify(command_line.result) else: abort(command_line.error)
def test_command_with_error(self): program = CommandLine() try: program.parse_command_line('add123') except CommandLineException as e: self.assertEqual(str(e), 'command line is not valid.')
def test_command(self): program = CommandLine() program.parse_command_line('add') state = program.get_state() self.assertEqual(state['state'], 'command') self.assertEqual(state['command'], 'add')
def __init__(self, new_start_message): CommandLine.__init__(self) self.output = new_start_message
def test_extract_command(self): commandLine = CommandLine() json = {'command': 'ps -ef'} self.assertEqual(commandLine.extract_command(json), ['ps', '-ef'])
def __ensure_no_mitmdump(self): CommandLine.execute( f'kill -9 $(lsof -t -i :{self.port}) > /dev/null 2>&1')
def __init__(self, new_output): CommandLine.__init__(self) self.output = new_output
University ID = acp15gr Registration Number = 150105918 ------------------------------------------------------------ ''' from command_line import CommandLine from stop_list import StopList from create_index import CreateIndex from load_querie_TFIDF import LoadQuerie_TFIDF from load_querie_TF import LoadQuerie_TF from load_querie_B import LoadQuerie_B from print_result import PrintResult from querie_dict import QuerieDict if __name__ == '__main__': commandLine = CommandLine() ################################# # Load StopList # ################################# stop = StopList(commandLine.getStopListFile(), commandLine.getStem()) ################################# # Load IndexFile # ################################# if (commandLine.getCreateIndex()): index = CreateIndex(commandLine.getIndexFile(), stop.stops, commandLine.getCollection(), True, commandLine.getStem(), commandLine.getToken()) else: index = CreateIndex(commandLine.getIndexFile())
def __init__(self, output): CommandLine.__init__(self) self.output = output
def test_bad_json(self): commandLine = CommandLine() json = {'not_a_program': 'never_mind'} self.assertFalse(commandLine.extract_command(json))
def test_empty(self): program = CommandLine() program.parse_command_line('') state = program.get_state() self.assertEqual(state['state'], 'empty state')
def test_command_line(self): sys.argv = ['ScriptedJsonEditor', 'JsonEditorJobs.json'] self.CLo = CommandLine() jobsFile = self.CLo.get_jobs_file() assert jobsFile == 'JsonEditorJobs.json', jobsFile
def test_command_line_no_jobs_file_specified(self, print_): sys.argv = ['ScriptedJsonEditor'] with patch('builtins.input', return_value=''): self.CLo = CommandLine() jobsFile = self.CLo.get_jobs_file() assert jobsFile is None, jobsFile
def test_process_without_json(self): commandLine = CommandLine() request = RequestMock() self.assertFalse(commandLine.process(request)) self.assertEqual(commandLine.error, 400)
class Command(Cmd): """ Command File Version 1 """ c = Controller() cl = CommandLine() def __init__(self): Cmd.__init__(self) self.prompt = ">>> " self.my_name = "unknown" # load and save valid employee into the database def valid_employee(self, file_name): employees = self.c.load_file(file_name) if employees: while True: ans = input("There are " + str(len(employees['Valid'])) + " Employees validated in the file" "\n Do you want to add them to the Database?" "\n [Y/N]" "\n>>>") if ans.upper() == "Y": self.add_data(employees['Valid']) break elif ans.upper() == "N": print("Data not added to the database") break else: print("Invalid input try again") # load and save invalid employee into the database def invalid_employee(self, file_name): employees = self.c.load_file(file_name) if len(employees["Invalid"]) is not 0: while True: ans = input("There's" + str(len(employees['Invalid'])) + " Employee(s) invalid" "\n Do you want to save to invalid.csv?" "\n [Y/N]" "\n >>>") if ans.upper() == "Y": self.c.save_invalid(employees['Invalid']) break elif ans.upper() == "N": print("Invalid Data not saved") break else: print("Invalid Input") def do_store(self, file_name): self.valid_employee(file_name) self.invalid_employee(file_name) # Jono def add_data(self, content): """ Adds file to database :param content: content from loaded file (List) :return: """ self.c.add_to_database(content) print("items added to database") def get_all_employees(self): return self.c.get_all_employees() # Chami def do_save(self, file_name): """ Syntax: save [file_name] :param file_name: a string representing a file name e.g example.txt :return: None """ # destination = F:\ARA3\Python\Assignment\test if file_name: employee_list = self.get_all_employees() self.c.save_file(file_name, employee_list) print(file_name) else: print("File did not save.") # Renee def do_chart(self, option): """ Syntax: to output a Bar Chart or Pie Chart :param option: option indicates what chart /a to view average sale and average salary in the bar chart, /sb to view the sales of individual employee in the bar chart /sl to view the sales of individual employee in the line chart /sp to view the salary detail of individual employee in the pie chart :return: """ if option and option.strip(): if option.lower() == "/a": self.c.print_chart_average() elif option.lower() == "/sb": self.c.print_chart_sales() elif option.lower() == "/sp": self.c.print_chart_pie() elif option.lower() == "/sl": self.c.print_chart_line() else: print("Invalid input try again") else: print("please enter your option") # Jono def do_quit(self, line): """ To quit the application :param line: :return: """ print("Quitting.....") return True def command_line_arguments(self): self.cl.greeting() self.cl.set_name() self.cl.set_number_of_command()
def __start_mitm(self): # import ipdb # ipdb.set_trace(context=5) self.mitm_proc = CommandLine.execute( f'mitmdump -p {self.port} -s test/analytics_logger.py > /dev/null 2>&1 &' )