def upload(self): xml_uploader = uploader.Uploader(self.__save_path(), s3_filepath=self.slug) xml_url = xml_uploader.upload() # Uploading each MP3 file for item in self.items: mp3_uploader = uploader.Uploader(item.file, s3_filepath=self.slug) mp3_url = mp3_uploader.upload() return xml_url
def test_upload_bundle(self): self.mock_bundle.openmrs_patient = mock.MagicMock() mock_location = mock.MagicMock() upload_handler = uploader.Uploader(self.mock_client) upload_handler.upload_openmrs_bundle(self.mock_bundle, mock_location) self.assertTrue(self._upload_resource.called) self.assertEqual(self.mock_bundle.openmrs_patient.base.new_id, '123')
def test_failed_column_null_check(self): item = "" test_result = True uploader_instance = uploader.Uploader(uploader.log) try: uploader_instance.column_null_check(item) except Exception: test_result = False self.assertFalse(test_result)
def __enter__(self): self.params = params.Params() self.fridge = fridge.Fridge(self, self._nowait) self.uploader = uploader.Uploader(self) self.configwaiter = configwaiter.ConfigWaiter(self) self.params.load() self.set_sensors(sensor.make_sensor(self)) asyncio.get_event_loop().add_signal_handler(signal.SIGHUP, self.reload_signal) return self
def test_failed_csv_null_check(self): csv_path = "index_null.csv" test_result = True uploader_instance = uploader.Uploader(uploader.log) try: uploader_instance.csv_null_check(csv_path) except Exception: test_result = False self.assertFalse(test_result)
def __init__(self): self.evt = event.Event() self.motion = motion.Motion() #actuator class self.sonic = sonic_sensor.SonicSensor() self.camera = camera.Camera() #sencer class self.uploader = uploader.Uploader() #sencer class self.motion.evt += self.camera.execute self.motion.evt += self.uploader.execute self.sonic.evt += self.camera.execute self.sonic.evt += self.uploader.execute
def __init__(self, root_path, config): self._root_path = root_path self._source_map = source_map.SourceMap(os.path.join(self._root_path, config["source_map_name"])) self._download_folder = config["download_folder"] credential_path = os.path.join(self._root_path, "google-application-credentials.json") self._uploader = uploader.Uploader(self._root_path, credential_path, gcs_path=config["gcs_path"], bucket_name=config["bucket_name"])
def __init__(self): self.evt = event.Event() self.camera = camera.Camera() #actuator class self.uploader = uploader.Uploader() #actuator class self.led = led.Led() self.motion = motion_sensor.MotionSensor() #sencor class self.sonic = sonic_sensor.SonicSensor() #sensor class self.motion.event_handlers += self.camera.shutter self.motion.event_handlers += self.uploader.execute self.sonic.evt += self.camera.shutter self.sonic.evt += self.uploader.execute
def __handle_download_idb_start(self, client, idb_name): # TODO: Check the idb_name exists in the idb db if not os.path.exists(os.path.join(self.__idbs_path, idb_name)): raise IDBNotFoundError( "Client requested an IDB that does not exist: {}".format( idb_name), RequestType.DOWNLOAD_IDB_FILE_NOT_FOUND.value) # Adds the upload job to the server client.add_job( uploader.Uploader(self.__logger, client, os.path.join(self.__idbs_path, idb_name)))
def test_ascii_check(self): item = "1" test_result = True uploader_instance = uploader.Uploader(uploader.log) try: uploader_instance.ascii_check(item) except Exception as e: print(e) test_result = False self.assertTrue(test_result)
def __init__(self): if len(sys.argv) != 2: self.usage() sys.exit(1) config_filepath = sys.argv[1] self.config = self.load_config(config_filepath) self.log_file = self.init_logging() self.screenshotter = screenshotter.Screenshotter(self.config) if not self.config.get('skip_upload'): self.uploader = uploader.Uploader(self.config)
def test_failed_check_plot_csv_data(self, csv_null_check_mock, ascii_check_mock, number_check_mock): csv_path = "data/error_test.csv" # csv_null_check_mock.return_value ="" number_check_mock.return_value = True test_result = True uploader_instance = uploader.Uploader(uploader.log) try: uploader_instance.check_plot_csv_data(csv_path) except Exception: test_result = False self.assertFalse(test_result)
def _initialize(self): # Create state directory. if not os.path.exists(K.STATE_DIR): os.mkdir(K.STATE_DIR) # Create upload thread (started in run() below). self._uploader = uploader.Uploader(self._main_cq, self._uploader_termination_event) # Create data sources. GPIO.setmode(GPIO.BCM) # required before Wind() self._uploader.add_data_source(temperature.Temperature(), True) self._uploader.add_data_source(metadata.Metadata(), False) # Import modules only when enabled, since some again import optional libraries (e.g. DHT). # In demo mode, enable all and import demo instances. if True: # TODO: Make wind optional. if C.DEMO_MODE_ENABLED(): import demo.demo_wind as wind # @UnusedImport else: import wind # @Reimport self._uploader.add_data_source(wind.Wind(), True) if C.DHT_ENABLED() or C.DEMO_MODE_ENABLED(): if C.DEMO_MODE_ENABLED(): import demo.demo_dht as dht # @UnusedImport else: import dht # @Reimport self._uploader.add_data_source(dht.Dht(), True) if C.ADC_ENABLED() or C.DEMO_MODE_ENABLED(): if C.DEMO_MODE_ENABLED(): import demo.demo_spi_adc as spi_adc # @UnusedImport else: import spi_adc # @Reimport self._uploader.add_data_source(spi_adc.SpiAdc(), True) if C.HUAWEI_ENABLED() or C.DEMO_MODE_ENABLED(): if C.DEMO_MODE_ENABLED(): import demo.demo_huawei_status as huawei_status # @UnusedImport else: import huawei_status # @Reimport self._uploader.add_data_source(huawei_status.HuaweiStatus(), True) if C.DOOR_ENABLED() or C.DEMO_MODE_ENABLED(): if C.DEMO_MODE_ENABLED(): import demo.demo_door as door # @UnusedImport else: import door # @Reimport self._uploader.add_data_source(door.Door(), True) if C.PILOTS_ENABLED() or C.DEMO_MODE_ENABLED(): if C.DEMO_MODE_ENABLED(): import demo.demo_pilot_count as pilot_count # @UnusedImport else: import pilot_count # @Reimport self._uploader.add_data_source(pilot_count.PilotCount(), True)
def test_check_csv_data(self, csv_null_check_mock, ascii_check_mock, number_check_mock, column_null_check_mock, check_plot_csv_data_mock): csv_path = "index.csv" # csv_null_check_mock.return_value ="" number_check_mock.return_value = True test_result = True uploader_instance = uploader.Uploader(uploader.log) try: uploader_instance.check_csv_data(csv_path) except Exception as e: print(e) test_result = False self.assertTrue(test_result)
def main(): abus = Bus() bbus = Bus() cbus = Bus() ct = collector.Collector(abus) rt = recorderdb.RecorderDB(abus, bbus, cbus) ut = uploader.Uploader(bbus, cbus) ht = hearbeat.Hearbeat() ct.start() rt.start() ut.start() ht.start() ct.join() rt.join() ut.join() ht.join()
def create_sink(sink_type: str, url: str) -> uploader.Uploader: client_ = getattr(fhir_client, _CLIENT_MAP[sink_type]) return uploader.Uploader(client_(url))
import os import socket import keyboard import uploader import pickle if __name__ == '__main__': path = "my_directory/" files_list = os.listdir(path) ObjectProgress = uploader.progress(files_list) sock = socket.socket() sock.bind(('', 9432)) sock.listen(len(files_list)) uploader = uploader.Uploader(files_list, len(files_list)) uploader.start() keyboard.hook(uploader.killAllProcess) while uploader.is_active(): conn, addr = sock.accept() data = conn.recv(1024) data = pickle.loads(data) if data["bool"] == True: ObjectProgress.AddDone(data["data"]) else: ObjectProgress.AddError(data["data"]) print(ObjectProgress.GetDone(), ObjectProgress.GetError(), ObjectProgress.GetTotal()) print("Done uploaded:")
threads = 1 debug = False for opt, arg in opts: if opt in ('-h', '--help'): usage() sys.exit() elif opt in ('-l', '--login'): login = arg elif opt in ('-p', '--password'): password = arg elif opt in ('-t', '--threads'): threads = int(arg) elif opt in ('-d', '--debug'): debug = True try: for opt, arg in opts: if opt in ('-r', '--recursive'): chomik_path, dirpath = args u = uploader.Uploader(login, password, debug = debug) if threads > 1: u.upload_multi(chomik_path, dirpath, threads) else: u.upload_dir(chomik_path, dirpath) elif opt in ('-u', '--upload'): chomik_path, filepath = args u = uploader.Uploader(login, password, debug = debug) u.upload_file(chomik_path, filepath) except ValueError, e: print e print "Blad: Musisz podac zarowno sciezke na chomiku, jak i na dysku. Ktoras z tych sciezek opusciles"
def test_number_check(self): item = "1" uploader_instance = uploader.Uploader(uploader.log) self.assertTrue(uploader_instance.number_check(item))
def catalysis_main(): print("Beginning catalysis.\n") # Reset session-dependent globals. catalysis_globals.directory = "" catalysis_globals.Invalid.max_err = 1 catalysis_globals.Invalid.err_count = 0 # Reset session-dependent class variables. object_classes.Profile.suffix_dicts = {} for row in {"Popup", "Sound", "Music", "Place", "Evidence", "Profile"}: active_obj = getattr(object_classes, row) active_obj.chain = [0] try: if not catalysis_globals.test_mode: catalysis_globals.directory, upload_dict, max_err = ( upload_parser.parse_file()) catalysis_globals.Invalid.max_err = max_err else: catalysis_globals.directory = "test_lib" macro_dict, config_dict = macro_parser.parse_file(macro_test) template, suffix_dicts, object_dict = ( object_parser.parse_file(config_dict, obj_test)) json_data = frame_parser.parse_file( template, suffix_dicts, object_dict, macro_dict, config_dict, frame_test) json_data = json.dumps(json_data, separators=(',', ':')) except catalysis_globals.RestartSignal: # A standard error has occurred. Send it up to the main loop. raise except Exception: print( "Unknown error observed! Please send your documents to Enthalpy, " "especially err.txt, which has been automatically created." ) error_file = catalysis_globals.get_file_name("err.txt") with open(error_file, "w") as f: traceback.print_exc(file=f) catalysis_globals.terminate() # Write data to file. output_file = catalysis_globals.get_file_name("testData.txt") open(output_file, "w").write('//Definition//Def6\n' + json_data) if not catalysis_globals.test_mode: try: upload_dict["trial_id"] = int(upload_dict["trial_id"]) except ValueError: print("Choosing not to upload data...") else: print(( "Choosing to upload data to trial {}. Press enter to " + "continue.").format(upload_dict["trial_id"])) print( "If this was not the trial ID you wanted, type other " "symbols and then hit enter." ) # Due to the codec, you need a bytestring here. do_not_upload = input() if not do_not_upload: upload_manager = uploader.Uploader(upload_dict) print("Catalysis complete!") catalysis_globals.terminate()
def test_instantiation(self): ul = widgets.MyListWidget() self.assertNotEqual(uploader.Uploader(ul), None)
def test_failed_number_check(self): item = "a" uploader_instance = uploader.Uploader(uploader.log) self.assertFalse(uploader_instance.number_check(item))
import errors import logger import reporter import exporter import uploader import calculator import idc from CGM import cgm from Stick import stick from Pump import pump from Profiles import bg, basal, net, isf, csf, iob, cob, targets # Define instances Logger = logger.Logger("loop") Exporter = exporter.Exporter() Uploader = uploader.Uploader() # CLASSES class Loop(object): def __init__(self): """ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INIT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ # Initialize start/end times self.t0 = None self.t1 = None
def test_fetch_location(self): upload_handler = uploader.Uploader(self.mock_client) self.mock_client.get_resource.return_value = { 'entry': [{ 'not_location': 'location' }] } location = upload_handler.fetch_location() self.assertEqual( location, {'8d6c993e-c2cc-11de-8d13-0010c6dffd0f': 'Unknown Location'}) self.mock_client.get_resource.return_value = { 'entry': [{ 'resource': { 'resourceType': 'Location', 'id': '8d6c993e-c2cc-11de-8d13-0010c6dffd0f', 'text': { 'status': 'generated', 'div': '<div xmlns="http://www.w3.org/1999/xhtml"><h2>Unknown ' 'Location</h2><h2/></div>' }, 'status': 'active', 'name': 'Unknown Location' } }, { 'resource': { 'resourceType': 'Location', 'id': '7f65d926-57d6-4402-ae10-a5b3bcbf7986', 'text': { 'status': 'generated', 'div': '<div ' 'xmlns="http://www.w3.org/1999/xhtml"><h2>Pharmacy</h2></div>' }, 'status': 'active', 'name': 'Pharmacy' } }, { 'resource': { 'resourceType': 'Location', 'id': '7fdfa2cb-bc95-405a-88c6-32b7673c0453', 'text': { 'status': 'generated', 'div': '<div ' 'xmlns="http://www.w3.org/1999/xhtml"><h2>Laboratory</h2></div>' }, 'status': 'active', 'name': 'Laboratory' } }] } location = upload_handler.fetch_location() self.assertEqual( location, { '8d6c993e-c2cc-11de-8d13-0010c6dffd0f': 'Unknown Location', '7f65d926-57d6-4402-ae10-a5b3bcbf7986': 'Pharmacy', '7fdfa2cb-bc95-405a-88c6-32b7673c0453': 'Laboratory' })
def test_upload_bundle_gcp(self): self.mock_bundle.patient = None upload_handler = uploader.Uploader(self.mock_client) upload_handler.upload_bundle(self.mock_bundle) self.assertFalse(self._upload_resource.called)