def csv_list_scheduled_jobs(self): self.logger.info('Health : Listing scheduled jobs') file_tasks=self.output_dir + '_tasks.csv' with open(file_tasks, 'wb') as tasks_logs: proc=subprocess.Popen(["schtasks.exe",'/query','/fo','CSV'],stdout=subprocess.PIPE) res = proc.communicate() res = get_terminal_decoded_string(res[0]) write_to_output(res, tasks_logs, self.logger) with open(file_tasks, "r") as fr, open(self.output_dir,'ab') as fw: csv_writer = get_csv_writer(fw) for l in fr.readlines(): l = l.decode('utf8')[:-1].replace('"', '') if l.find(',') !=-1: write_to_csv([self.computer_name, 'Scheduled jobs'] + l.split(','), csv_writer)
def csv_list_scheduled_jobs(self): self.logger.info('Health : Listing scheduled jobs') file_tasks = self.output_dir + '_tasks.csv' with open(file_tasks, 'wb') as tasks_logs: proc = subprocess.Popen(["schtasks.exe", '/query', '/fo', 'CSV'], stdout=subprocess.PIPE) res = proc.communicate() res = get_terminal_decoded_string(res[0]) write_to_output(res, tasks_logs, self.logger) with open(file_tasks, "r") as fr, open(self.output_dir, 'ab') as fw: csv_writer = get_csv_writer(fw) for l in fr.readlines(): l = l.decode('utf8')[:-1].replace('"', '') if l.find(',') != -1: write_to_csv([self.computer_name, 'Scheduled jobs'] + l.split(','), csv_writer)
def _csv_list_scheduled_jobs(self): self.logger.info('Health : Listing scheduled jobs') file_tasks=self.output_dir + '_tasks.csv' with open(file_tasks,'wb') as tasks_logs: proc=subprocess.Popen(["schtasks.exe",'/query','/fo','CSV'], stdout=subprocess.PIPE) res = proc.communicate() res = get_terminal_decoded_string(res[0]) write_to_output(res, tasks_logs, self.logger) with open(file_tasks,"r") as fr, open(self.output_dir + "_scheduled_jobs.csv",'wb') as fw: csv_writer = get_csv_writer(fw) #fw.write('"Computer Name"|"Type"|"Name"|"Time"|"State"\r\n') for l in fr.readlines(): l = l.decode('utf8') if l.find('\\') > 0: l = l[:-1].replace('"', '') # remove the end of line arr_write = [self.computer_name, 'Scheduled jobs'] + l.split(',') write_to_csv(arr_write, csv_writer) record_sha256_logs(self.output_dir +'_scheduled_jobs.csv',self.output_dir +'_sha256.log')
def get_breadcrumbs(url): page_source = urllib.urlopen(url).read() """ check if the product exists (if 'clp-breadcrumb' is not found in the page source, it means that the page redirected to the flipkart home page, which means that the product does not exist) """ if "clp-breadcrumb" not in page_source: return [] # yes, the product exists write_to_output(page_source, output_file) # get only the clp-breadcrumb div command = "awk '/clp-breadcrumb/,/\<\/div\>/' " + output_file output = run_command_and_get_output(command, temp_file) write_to_output(output, output_file) # get only the values between the starting <a and ending </a> command = "awk '/\<a/,/\<\/a\>/' " + output_file output = run_command_and_get_output(command, temp_file) write_to_output(output, output_file) # get only the values between the <a>values...</a>tag command = "ag -o '\\t[^\<^\>]*\\n' " + output_file output = run_command_and_get_output(command, temp_file) write_to_output(output, output_file) # remove all the spaces from the output values command = "ag -o '[^\\t^\\n].*' " + output_file output = run_command_and_get_output(command, temp_file) write_to_output(output, output_file) return_list = [] with open(output_file, "r") as f: for line in f.read().split("\n"): if line not in dont_return_breadcrumbs: return_list.append(line) print(return_list) return return_list
def _csv_list_scheduled_jobs(self): self.logger.info('Health : Listing scheduled jobs') file_tasks = self.output_dir + '_tasks.csv' with open(file_tasks, 'wb') as tasks_logs: proc = subprocess.Popen(["schtasks.exe", '/query', '/fo', 'CSV'], stdout=subprocess.PIPE) res = proc.communicate() res = get_terminal_decoded_string(res[0]) write_to_output(res, tasks_logs, self.logger) with open(file_tasks, "r") as fr, open(self.output_dir + "_scheduled_jobs.csv", 'wb') as fw: csv_writer = get_csv_writer(fw) #fw.write('"Computer Name"|"Type"|"Name"|"Time"|"State"\r\n') for l in fr.readlines(): l = l.decode('utf8') if l.find('\\') > 0: l = l[:-1].replace('"', '') # remove the end of line arr_write = [self.computer_name, 'Scheduled jobs' ] + l.split(',') write_to_csv(arr_write, csv_writer) record_sha256_logs(self.output_dir + '_scheduled_jobs.csv', self.output_dir + '_sha256.log')