Esempio n. 1
0
def _cmd_init(args, extra=None):
    if os.path.isfile(
            os.path.join(JustUpdateConstants.REPO_FOLDER,
                         "config.ju")) or os.path.isdir(
                             JustUpdateConstants.REPO_FOLDER):
        logging.warning(
            "A JustUpdate repository already exists at this location.")
        return True

    # setup a new repo.
    app_name = prompt("Application Name:", "MyAwezomeApp")
    app_author = prompt("Application Author:", "MyAwesomeCompany")
    update_url = prompt("Url to ping for updates:")
    client_config_dir = prompt(
        "Where to place the client_config.py file (used by your application): ",
        default=".")

    if update_url.endswith("/") == False:
        update_url += "/"
    logging.info("Creating folder structure.")
    os.makedirs(JustUpdateConstants.REPO_FOLDER)
    logging.info("Creating config.")
    c = Config()
    c.set("app_name", app_name)
    c.set("app_author", app_author)
    c.set("update_url", update_url)
    c.save(os.path.join(JustUpdateConstants.REPO_FOLDER, "config.ju"))
    logging.info("Saving config.")
    logging.info("Copying templates.")
    shutil.copytree(
        os.path.join(JustUpdateConstants.MODULE_FOLDER, "templates"),
        os.path.join(JustUpdateConstants.REPO_FOLDER, "templates"))
    logging.info("Templates copied.")
    logging.info("Creating client config.")
    client_config_data = """class ClientConfig():
	app_name = "{}"
	app_author = "{}"
	update_url = "{}"
""".format(app_name, app_author, update_url)
    with open(os.path.join(client_config_dir, "client_config.py"), "w") as cc:
        cc.write(client_config_data)
    logging.info("Initialization done.")
Esempio n. 2
0
 def _fill_out_credentials(self):
     logging.info("SCPUploader credentials setup.")
     host = prompt("SCP Host: ")
     port = prompt("SCP Port: ", default=22)
     username = prompt("SCP username: "******"SCP password (either for username or for ssh key): ",
         allow_empty=True)
     key_file = prompt("SSH Key (if applicable): ", default=None)
     remote_path = prompt("Remote path to upload to: ")
     self.settings = self.manager.save_settings(
         "scp", {
             "host": host,
             "port": port,
             "username": username,
             "password": password,
             "key_file": key_file,
             "remote_path": remote_path
         })
     return self.connect()