def setUp(self): log = logging.getLogger("setUp") self.tearDown() log.debug("creating {0}".format(test_dir_path)) os.makedirs(test_dir_path) log.debug("opening s3 connection") self._s3_connection = boto.connect_s3()
def _main_loop(self): self._s3_connection = motoboto.connect_s3(identity=self._user_identity) self._initial_inventory() if self._test_script.get("verify-before", False): self._verify_before() self._load_frequency_table() self._key_name_generator = self._key_name_manager.key_name_generator() # do an initial delay so all customers don't start at once self._delay() while not self._halt_event.is_set(): # run a randomly selected test function test_function = self._frequency_table[random.randint(0, 99)] try: test_function() except Exception: self._error_count += 1 self._log.exception("test_function error #{0}".format( self._error_count)) self._delay() if self._test_script.get("verify-after", False): self._verify_after() if self._test_script.get("audit-after", False): self._audit_after() self._s3_connection.close() self._log.info("{0} errors".format(self._error_count))
def main(): """ main program entry point returns 0 for normal termination """ _initialize_logging() log = logging.getLogger("main") log.debug("program starts") try: motoboto_connection = motoboto.connect_s3() except Exception: log.exception("Unable to connect to motoboto") return 1 try: command, args = parse_arguments() except ValueError: instance = sys.exc_info()[1] motoboto_connection.close() log.error("Invalid arguments: {0}".format(instance)) print(usage) return 2 full_args = [ motoboto_connection, ] full_args.extend(args) try: _dispatch_table[command](*full_args) except Exception: motoboto_connection.close() log.exception("{0} {1}".format(command, full_args)) return 3 motoboto_connection.close() log.debug("program terminates normally") return 0
def main(): """ main program entry point returns 0 for normal termination """ _initialize_logging() log = logging.getLogger("main") log.debug("program starts") try: motoboto_connection = motoboto.connect_s3() except Exception: log.exception("Unable to connect to motoboto") return 1 try: command, args = parse_arguments() except ValueError: instance = sys.exc_info()[1] motoboto_connection.close() log.error("Invalid arguments: {0}".format(instance)) print(usage) return 2 full_args = [motoboto_connection] full_args.extend(args) try: _dispatch_table[command](*full_args) except Exception: motoboto_connection.close() log.exception("{0} {1}".format(command, full_args)) return 3 motoboto_connection.close() log.debug("program terminates normally") return 0
def archive_file(args, nimbusio_identity, file_name): log = logging.getLogger("archive_file") s3_emulator = motoboto.connect_s3(nimbusio_identity) if args.collection_name is None: bucket = s3_emulator.default_bucket else: bucket = s3_emulator.get_bucket(args.collection_name) key_name = "".join([args.prefix, file_name]) archive_key = Key(bucket, key_name) log.info("archiving {0} as key {1} to collection {2}".format(file_name, archive_key, bucket)) file_path = os.path.join(args.watch_path, file_name) with open(file_path, "rb") as input_file: archive_key.set_contents_from_file(input_file) log.info("archive successful version identifier = {0}".format( archive_key.version_id)) s3_emulator.close()
def setUp(self): log = logging.getLogger("setUp") log.debug("start") self.tearDown() self._s3_connection = motoboto.connect_s3() log.debug("finish")