コード例 #1
0
 def test_get(self, whole_config):
     # Setup
     desired_conf = whole_config
     # Exercise
     cr = ConfigReader('data_test')
     actual_conf = cr.svt_config
     # Verify
     assert desired_conf == actual_conf
     assert cr.get('sql_alchemy') == desired_conf['sql_alchemy']
     assert cr.get('sql_alchemy',
                   'host') == desired_conf['sql_alchemy']['host']
     assert cr.get('sql_alchemy',
                   'port') == desired_conf['sql_alchemy']['port']
コード例 #2
0
def main():
    conf = ConfigReader().conf
    if conf.get("log_host") and conf.get("log_port"):
        logger = app_logger(conf["log_host"], conf["log_port"])
    else:
        logger = app_logger()
    logger.info("Logging initialized.")

    search = "set hostname"
    backup_file = conf["incoming_path"] + conf["backup_name"]

    # make sure there is a backup to work on
    if not os.path.exists(backup_file):
        logger.critical("Cannot find backup_file in backup file, aborting")
        print("No backup to check, aborting")
        sys.exit(-1)

    timestamp = time.strftime("_%Y-%m-%d_%H-%m",
                              time.gmtime(os.path.getmtime(backup_file)))

    hostname = get_hostname(backup_file, search)
    if not hostname:
        logger.critical("Cannot find hostname in backup file, aborting")
        print("Cannot find hostname in backup file, aborting")
        sys.exit(-1)
    print(f"found hostname {hostname}")
    target_dir = conf["archive_path"] + hostname + "/"
    target_file = hostname + timestamp + ".conf"

    print(f"Archive will be written to {target_dir}{target_file}")
    logger.info(f"Archive will be written to {target_dir}{target_file}")

    if not os.path.exists(target_dir):
        try:
            os.mkdir(target_dir)
        except PermissionError:
            print("Access denied, creating target directory {target_dir}")
            sys.exit(-1)

    try:
        shutil.move(backup_file, target_dir + target_file)
    except Exception:
        print(f"Error moving archive to directory {target_dir}")
        sys.exit(-1)
コード例 #3
0
print(' ### PiMusicDisplay ### ')

now = datetime.datetime.now()
print(now)

debug = False
if len(sys.argv) > 1 and sys.argv[1] == "-d":
    debug = True
    print('Running in debug mode')

config = ConfigReader()
config.printConfig()

# create system (eg backlight controller)
system = System(config.get())

root = tk.Tk()
win = Window(root, system, config.get())

# init ir-remote
remote = RemoteIR(system, config, win)

# init mopidy interface
Mopidy = IF_Mopidy(config.get())

# init spotiy-connect-web interface
SpotConnWeb = IF_SpotifyConnectWeb(config.get())

coverLoader = CoverLoader(config.get())