def main(): config = MalwasmConfig().get('database') parser = argparse.ArgumentParser(description = 'Malwasm create DB') parser.add_argument('--version', action='version', version="%(prog)s version " + MALWASM_VERSION) # software configuration required param parser.add_argument('-f', '--force', action='store_true', default=False, help='Force to drop the database and use the new schema') # database configuration parser.add_argument('-u', '--username', action='store', default=config['username'], help='Database username') parser.add_argument('-p', '--password', action='store', default=config['password'], help='Database password') parser.add_argument('-d', '--db', action='store', default=config['dbname'], help='Database name') parser.add_argument('--host', action='store', default=config['host'], help='Database hostname') # logging configuration parser.add_argument('--debug', action='store_const', const=logging.DEBUG, default=logging.CRITICAL, dest='logging', help='Show debug output') # parse cli argument r = parser.parse_args() logging.basicConfig(level=r.logging) # build the new configuration c = { 'username': r.username, 'password': r.password, 'dbname': r.db, 'host': r.host, } config.update(c) ret = os.EX_SOFTWARE try: m = MalwasmDb(config) if r.force: m.close() m.generate() print "Database '%s' correctly created!" % r.db ret = os.EX_OK except MalwasmExceptDbConn as e: print >> sys.stderr, "Database connection error:", e except MalwasmExceptDb as e: print >> sys.stderr, "Database error:", e except Exception as e: print >> sys.stderr, e sys.exit(ret)
def main(): parser = argparse.ArgumentParser(description = 'Malwasm insert XML into DB') parser.add_argument('--version', action='version', version="%(prog)s version " + MALWASM_VERSION) # software configuration required param parser.add_argument('-d', '--dir', action='store', required=True, help='Directory where generated data are stocked') parser.add_argument('-i', '--sample-id', action='store', required=True, help='Sample id') config = MalwasmConfig().get('database') # database configuration parser.add_argument('-u', '--username', action='store', default=config['username'], help='Database username') parser.add_argument('-p', '--password', action='store', default=config['password'], help='Database password') parser.add_argument('--db', action='store', default=config['dbname'], help='Database name') parser.add_argument('--host', action='store', default=config['host'], help='Database hostname') # logging configuration parser.add_argument('--debug', action='store_const', const=logging.DEBUG, default=logging.INFO, dest='logging', help='Show debug output') # parse cli argument r = parser.parse_args() logging.basicConfig(level=r.logging) # build the new configuration c = { 'username': r.username, 'password': r.password, 'dbname': r.db, 'host': r.host, } config.update(c) ret = os.EX_SOFTWARE try: c = connect_db(config) try: os.mkdir(r.dir) except: pass path_memory = os.path.join(r.dir, "memory") try: os.mkdir(path_memory) except: pass build_xml(c, r.sample_id, r.dir) build_dump(c, r.sample_id, path_memory) c.close() ret = os.EX_OK except Exception as e: logging.exception(e) print >> sys.stderr, e sys.exit(ret)
def main(): parser = argparse.ArgumentParser(description = 'Malwasm insert XML into DB') parser.add_argument('--version', action='version', version="%(prog)s version " + MALWASM_VERSION) # software configuration required param #parser.add_argument('-e', '--exe', action='store', required=True, #help='Sample file related to the data') parser.add_argument('-d', '--dir', action='store', required=True, help='Directory where generated data are stocked') #parser.add_argument('--pin-param', action='store', default="", #help='Directory where generated data are stocked') config = MalwasmConfig().get('database') # database configuration parser.add_argument('-u', '--username', action='store', default=config['username'], help='Database username') parser.add_argument('-p', '--password', action='store', default=config['password'], help='Database password') parser.add_argument('--db', action='store', default=config['dbname'], help='Database name') parser.add_argument('--host', action='store', default=config['host'], help='Database hostname') # logging configuration parser.add_argument('--debug', action='store_const', const=logging.DEBUG, default=logging.INFO, dest='logging', help='Show debug output') # parse cli argument r = parser.parse_args() logging.basicConfig(level=r.logging) # build the new configuration c = { 'username': r.username, 'password': r.password, 'dbname': r.db, 'host': r.host, } config.update(c) ret = os.EX_SOFTWARE try: m = MalwasmDb(config) m.insert(r.dir) ret = os.EX_OK except MalwasmExceptDbConn as e: print >> sys.stderr, "Database connection error:", e except MalwasmExceptDb as e: print >> sys.stderr, "Database error:", e except Exception as e: logging.exception(e) print >> sys.stderr, e sys.exit(ret) conn.close() sys.exit(os.EX_OK)
def main(): config = MalwasmConfig().get('database') parser = argparse.ArgumentParser(description='Malwasm create DB') parser.add_argument('--version', action='version', version="%(prog)s version " + MALWASM_VERSION) # software configuration required param parser.add_argument( '-f', '--force', action='store_true', default=False, help='Force to drop the database and use the new schema') # database configuration parser.add_argument('-u', '--username', action='store', default=config['username'], help='Database username') parser.add_argument('-p', '--password', action='store', default=config['password'], help='Database password') parser.add_argument('-d', '--db', action='store', default=config['dbname'], help='Database name') parser.add_argument('--host', action='store', default=config['host'], help='Database hostname') # logging configuration parser.add_argument('--debug', action='store_const', const=logging.DEBUG, default=logging.CRITICAL, dest='logging', help='Show debug output') # parse cli argument r = parser.parse_args() logging.basicConfig(level=r.logging) # build the new configuration c = { 'username': r.username, 'password': r.password, 'dbname': r.db, 'host': r.host, } config.update(c) ret = os.EX_SOFTWARE try: m = MalwasmDb(config) if r.force: m.close() m.generate() print "Database '%s' correctly created!" % r.db ret = os.EX_OK except MalwasmExceptDbConn as e: print >> sys.stderr, "Database connection error:", e except MalwasmExceptDb as e: print >> sys.stderr, "Database error:", e except Exception as e: print >> sys.stderr, e sys.exit(ret)
def main(): parser = argparse.ArgumentParser(description='Malwasm insert XML into DB') parser.add_argument('--version', action='version', version="%(prog)s version " + MALWASM_VERSION) # software configuration required param parser.add_argument('-d', '--dir', action='store', required=True, help='Directory where generated data are stocked') parser.add_argument('-i', '--sample-id', action='store', required=True, help='Sample id') config = MalwasmConfig().get('database') # database configuration parser.add_argument('-u', '--username', action='store', default=config['username'], help='Database username') parser.add_argument('-p', '--password', action='store', default=config['password'], help='Database password') parser.add_argument('--db', action='store', default=config['dbname'], help='Database name') parser.add_argument('--host', action='store', default=config['host'], help='Database hostname') # logging configuration parser.add_argument('--debug', action='store_const', const=logging.DEBUG, default=logging.INFO, dest='logging', help='Show debug output') # parse cli argument r = parser.parse_args() logging.basicConfig(level=r.logging) # build the new configuration c = { 'username': r.username, 'password': r.password, 'dbname': r.db, 'host': r.host, } config.update(c) ret = os.EX_SOFTWARE try: c = connect_db(config) try: os.mkdir(r.dir) except: pass path_memory = os.path.join(r.dir, "memory") try: os.mkdir(path_memory) except: pass build_xml(c, r.sample_id, r.dir) build_dump(c, r.sample_id, path_memory) c.close() ret = os.EX_OK except Exception as e: logging.exception(e) print >> sys.stderr, e sys.exit(ret)