def manage_get_ITJW_top_30_menu(self): print('Please select from the below menu options\n') print( '1. Print top 30 to downloads folder with default name (No Headers)' ) print( '2. Print top 30 to downloads folder with default name (with Headers)' ) print('3. Return to Main Menu') print('or type exit to quit program\n') print('Please select option:\n') option_selected = input() if option_selected.lower() == 'exit': exit() elif option_selected == '': self.manage_get_ITJW_top_30_menu() elif int(option_selected) == 1: Top30CSVGenerator().generate_top_30_csv( ItJobsWatchHomePageTop30(itjobswatch_home_page_url()). get_top_30_table_elements_into_array()) print('Please check your downloads folder') self.manage_get_ITJW_top_30_menu() elif int(option_selected) == 2: top_30 = ItJobsWatchHomePageTop30(itjobswatch_home_page_url()) Top30CSVGenerator().generate_top_30_csv( top_30.get_top_30_table_elements_into_array(), os.path.expanduser('~/Downloads/'), 'ItJobsWatchTop30.csv', top_30.get_table_headers_array()) elif int(option_selected) == 3: self.menu_control() else: print('Please select an option from the menu or type exit') self.manage_get_ITJW_top_30_menu()
def create_top_30_using_default_location_and_default_name( self, generate_top_30_html_object): csv_generator_object = Top30CSVGenerator() csv_generator_object.generate_top_30_csv( generate_top_30_html_object.get_top_30_table_elements_into_array()) yield self.create_top_30_using_default_location_and_default_name os.remove(os.path.expanduser('~/Downloads/') + 'ItJobsWatchTop30.csv')
def create_top_30_test_csv(self, generate_top_30_html_object): csv_generator_object = Top30CSVGenerator() csv_generator_object.generate_top_30_csv( generate_top_30_html_object.get_top_30_table_elements_into_array(), TEST_RESOURCES_FOLDER, '/top_30_without_headers.csv') yield self.create_top_30_test_csv os.remove(TEST_RESOURCES_FOLDER + '/top_30_without_headers.csv')
def create_top_30_using_default_location_and_default_name( self, generate_top_30_html_object): csv_generator_object = Top30CSVGenerator() csv_generator_object.generate_top_30_csv( generate_top_30_html_object.get_top_30_table_elements_into_array()) yield self.create_top_30_using_default_location_and_default_name os.remove(f'{OUTPUT_LOC}ItJobsWatchTop30.csv')
def run_automation_head(self): top_30 = ItJobsWatchHomePageTop30(itjobswatch_home_page_url()) Top30CSVGenerator().generate_top_30_csv( top_30.get_top_30_table_elements_into_array(), os.path.expanduser('~/Downloads/'), 'ItJobsWatchTop30.csv', top_30.get_table_headers_array()) print('Please check your downloads folder')
def no_headers(): # If there is a pre-existing csv file this will remove it # This is to ensure the app always uses the newest data present if os.path.exists(os.getcwd() + "/ItJobsWatchTop30s3.csv"): os.remove(os.getcwd() + "/ItJobsWatchTop30s3.csv") live_response = requests.get("https://www.itjobswatch.co.uk/") if live_response.status_code: cwd = os.getcwd() + "/" top_30 = ItJobsWatchHomePageTop30(itjobswatch_home_page_url()) Top30CSVGenerator().generate_top_30_csv( top_30.get_top_30_table_elements_into_array(), cwd, 'ItJobsWatchTop30s3.csv', top_30.get_table_headers_array()) try: upload_file("ItJobsWatchTop30s3.csv", "eng74-final-project-bucket") download_file("eng74-final-project-bucket", "ItJobsWatchTop30s3.csv") except: pass # # If not then just download the s3 bucket data else: try: download_file("eng74-final-project-bucket", "ItJobsWatchTop30.csv") except: pass filename = "ItJobsWatchTop30s3.csv" data = pandas.read_csv(filename, header=0) joblist = list(data.values) return render_template('list.html', joblist=joblist)
def create_top_30_test_csv_with_headers_with_specified_location( self, generate_top_30_html_object): csv_generator_object = Top30CSVGenerator() csv_generator_object.generate_top_30_csv( generate_top_30_html_object.get_top_30_table_elements_into_array(), TEST_RESOURCES_FOLDER, 'top_30_with_headers.csv', 'yes') yield self.create_top_30_test_csv_with_headers_with_specified_location os.remove(f'{TEST_RESOURCES_FOLDER}top_30_with_headers.csv')
# print(i) def download_file(bucket, file_name): """ Function to download a given file from an S3 bucket """ BUCKET_NAME = bucket # replace with your bucket name KEY = file_name # replace with your object key s3 = boto3.resource('s3') s3.Bucket(BUCKET_NAME).download_file(KEY, 'ITJobsWatchTop30.csv') if __name__ == "__main__": live_response = requests.get("https://www.itjobswatch.co.uk/") if live_response.status_code: cwd = os.getcwd() + "/" top_30 = ItJobsWatchHomePageTop30(itjobswatch_home_page_url()) Top30CSVGenerator().generate_top_30_csv( top_30.get_top_30_table_elements_into_array(), cwd, 'ItJobsWatchTop30test.csv', top_30.get_table_headers_array()) upload_file("ItJobsWatchTop30test.csv", "eng74-final-project-bucket") download_file("eng74-final-project-bucket", "ItJobsWatchTop30test.csv") # # If not then just download the s3 bucket data else: download_file("eng74-final-project-bucket", "ItJobsWatchTop30.csv")
def run_automation_head_none(self): Top30CSVGenerator().generate_top_30_csv( ItJobsWatchHomePageTop30(itjobswatch_home_page_url()). get_top_30_table_elements_into_array()) print('Please check your downloads folder')