Beispiel #1
0
    def input_gear(self, monster):
        if len(self):
            print("Gear already exists for this task (" + monster + ").")
            if not input_bool(
                    "Are you sure that you want to overwrite existing gear?"):
                return
            else:
                self.slot_dict.clear()

        slots = [
            "helmet", "cape", "amulet", "ammo", "weapon", "offhand", "torso",
            "legs", "gloves", "boots", "ring"
        ]
        two_handed = False
        for slot in slots:
            if slot == "weapon":
                two_handed = input_bool("Is the weapon two_handed?")
            # Skip offhand slot if weapon is two-handed.
            if two_handed and slot == "offhand":
                continue
            print("Enter item for " + slot + " slot:")
            i = input()
            self.slot_dict[slot] = i
            print("Added " + i + " to " + slot + " slot.")

        print("Gear successfully added for " + monster + ".")
Beispiel #2
0
def create_nginx_redirect_config(env_file, hostname):
    if hostname.startswith("www."):
        redirect_from = hostname[4:]
    else:
        redirect_from = "www.%s" % hostname

    config_dst = Path(os.path.join(VHOSTD_DIR, redirect_from))

    redirect_prompt = (
        "Do you want to set 301 redirect from %s to %s? "
        "(requires domain to be already configured)"
    ) % (redirect_from, hostname)
    if input_bool(redirect_prompt):
        env_file["LETSENCRYPT_HOST"] = env_file["VIRTUAL_HOST"]
        env_file.save()
    else:
        env_file["LETSENCRYPT_HOST"] = hostname
        env_file.save()
        if config_dst.is_file():
            config_dst.unlink()
        return False

    with safe_open(REDIRECT_CONFIG, "r") as f:
        tpl = f.read()
    redirect_config = tpl.replace("domain.com", hostname)

    with safe_open(config_dst, "w") as f:
        f.write(redirect_config)

    return True
Beispiel #3
0
def reset_secret_key(env_file):
    print_secret_key(misago)
    print()
    if input_bool("Generate new secret key?", default=False):
        set_random_secret_key(env_file)
        env_file.save()
        print_setup_changed_message()
Beispiel #4
0
def run_facebook_signin_wizard(env_file):
    if input_bool("Enable sign-in with Facebook?"):
        run_facebook_key_wizard(env_file)
        run_facebook_secret_wizard(env_file)
        env_file["SOCIAL_AUTH_FACEBOOK_ENABLE"] = "yes"
    else:
        env_file["SOCIAL_AUTH_FACEBOOK_ENABLE"] = "no"
Beispiel #5
0
def change_twitter_signin_setup(env_file):
    print_twitter_signin_setup(misago)
    print()
    if input_bool("Change sign-in with Twitter setup?", default=False):
        run_twitter_signin_wizard(env_file)
        env_file.save()
        print_setup_changed_message()
def change_forum_index_setup(env_file):
    print_forum_index_setup(misago)
    print()
    if input_bool("Change forum index?", default=False):
        run_forum_index_wizard(env_file)
        env_file.save()
        print_setup_changed_message()
Beispiel #7
0
def change_github_signin_setup(env_file):
    print_github_signin_setup(misago)
    print()
    if input_bool("Change sign-in with GitHub setup?", default=False):
        run_github_signin_wizard(env_file)
        env_file.save()
        print_setup_changed_message()
Beispiel #8
0
def run_twitter_signin_wizard(env_file):
    if input_bool("Enable sign-in with Twitter?"):
        run_twitter_key_wizard(env_file)
        run_twitter_secret_wizard(env_file)
        env_file["SOCIAL_AUTH_TWITTER_ENABLE"] = "yes"
    else:
        env_file["SOCIAL_AUTH_TWITTER_ENABLE"] = "no"
Beispiel #9
0
def run_github_signin_wizard(env_file):
    if input_bool("Enable sign-in with GitHub?"):
        run_github_key_wizard(env_file)
        run_github_secret_wizard(env_file)
        env_file["SOCIAL_AUTH_GITHUB_ENABLE"] = "yes"
    else:
        env_file["SOCIAL_AUTH_GITHUB_ENABLE"] = "no"
def change_sentry_setup(env_file):
    print_sentry_setup(misago)
    print()
    if input_bool("Change Sentry logging?", default=False):
        run_sentry_wizard(env_file)
        env_file.save()
        print_setup_changed_message()
Beispiel #11
0
def change_timezone_setup(env_file):
    print_timezone_setup(misago)
    print()
    if input_bool("Change timezone configuration?", default=False):
        run_timezone_wizard(env_file)
        env_file.save()
        print_setup_changed_message()
Beispiel #12
0
def change_email_setup(env_file):
    print_email_setup(misago)
    print()
    if input_bool("Change e-mail configuration?", default=False):
        run_email_wizard(env_file)
        env_file.save()
        print_setup_changed_message()
Beispiel #13
0
def update_local_file(filename, directory, stored_contents):
  existing_contents = load_actual_file(filename, directory)
  if existing_contents != stored_contents:
    path = os.path.join(directory, filename)
    print('Stored config file %s differs from local version %s:' % (filename, path))
    print(diff_contents(existing_contents, stored_contents, fromfile=path, tofile=filename))
    if input_bool('Update contents of %s according to diff?' % path):
      write_file(path, stored_contents)
def change_debug_setup(env_file):
    print_debug_setup(misago)
    print()
    if input_bool("Change debug mode?", default=False):
        new_debug_mode = env_file.get("MISAGO_DEBUG",
                                      "").lower() not in BOOL_TRUE
        env_file["MISAGO_DEBUG"] = serialize_bool(new_debug_mode)
        env_file.save()
        print_setup_changed_message()
Beispiel #15
0
def change_hostname_setup(env_file):
    print_hostname_setup(misago)
    print()
    if input_bool("Change hostname?", default=False):
        run_hostname_wizard(env_file)
        env_file.save()
        print_setup_changed_message()
    elif run_nginx_wizard(env_file):
        print_setup_changed_message()
Beispiel #16
0
    def delete_task(self):
        if not len(self.tasks):
            print("There are no tasks currently recorded to delete.")
            return
        if self.selected_task is None:
            print("No task currently selected. Please select a task.")
            return

        print("The currently selected task is " + str(self.selected_task))
        if input_bool("Are you sure that you want to delete this task?"):
            t = self.selected_task
            self.tasks.remove(t)
            self.selected_task = None
            print("Task successfully removed.")
Beispiel #17
0
 def remove_gear_from_task(self):
     if not len(self.tasks):
         print("There are no tasks from which to remove gear.")
         return
     if self.selected_task is None:
         print("No task is currently selected. Please select a task.")
         return
     if not len(self.selected_task.gear):
         print("Task already has no gear.")
         return
     if input_bool("Are you sure that you want to remove gear from " +
                   str(self.selected_task) + "?"):
         self.selected_task.gear.clear()
         print("Gear removed from task.")
     else:
         print("Operation aborted.")
def change_daily_backup_setup(env_file):
    print_daily_backup_setup(misago)
    print()

    daily_backup_is_enabled = (env_file.get("MISAGO_DAILY_BACKUP",
                                            "").lower() == BOOL_TRUE)
    if daily_backup_is_enabled:
        backup_prompt = "Disable automatic daily backup?"
    else:
        backup_prompt = "Enable automatic daily backup?"

    if input_bool(backup_prompt, default=not daily_backup_is_enabled):
        new_daily_backup_mode = (env_file.get("MISAGO_DAILY_BACKUP",
                                              "").lower() != BOOL_TRUE)
        env_file["MISAGO_DAILY_BACKUP"] = serialize_bool(new_daily_backup_mode)
        env_file.save()
        print_setup_changed_message()
Beispiel #19
0
def create_nginx_location_config(hostname):
    config_filename = "%s_location" % hostname
    config_dst = Path(os.path.join(VHOSTD_DIR, config_filename))
    if config_dst.is_file():
        if save_cmp(VHOST_LOCATION_CONFIG, config_dst):
            # Skip rest of wizard because destination file already exists
            return True

        overwrite_prompt = (
            "config/vhost.d/%s already exists but appears to be modified, "
            "overwrite with default?"
        ) % config_filename
        if not input_bool(overwrite_prompt, default=False):
            return False
        config_dst.unlink()

    safe_copy(VHOST_LOCATION_CONFIG, config_dst)
    safe_copy(VHOST_LOCATION_CONFIG, Path(os.path.join(VHOSTD_DIR, hostname)))
    return True
Beispiel #20
0
def run_smtp_wizard(env_file):
    email_host_prompt = 'Enter your SMTP host (eg. "smtp.myprovider.com"): '
    email_host = None

    while not email_host:
        email_host = input(email_host_prompt).strip()
        if not email_host:
            email_host = None
            print("You have to enter a SMTP host.")
            print()

    email_user_prompt = "Enter your SMTP user name: "
    email_user = None

    while not email_user:
        email_user = input(email_user_prompt).strip()
        if not email_user:
            email_user = None
            print("You have to enter a SMTP user name.")
            print()

    email_password_prompt = "Enter your SMTP user password (optinal but recommended): "
    email_password = input(email_password_prompt).strip()

    email_ssl = input_bool("Enable SSL", default=False)
    email_tls = input_bool("Enable TLS", default=False)

    email_port_prompt = "Enter your SMTP port: "
    email_port = None

    while not email_port:
        email_port = input(email_port_prompt).strip()
        if not email_port:
            email_port = None
            print("You have to enter a SMTP port.")
            print()

    email_address_prompt = "Enter your site's e-mail address: "
    email_address = input(email_address_prompt).strip()

    while not email_address:
        email_address = input(email_address_prompt).strip()
        if not email_address:
            email_address = None
            print("You have to enter e-mail address.")
            print()

    email_from_prompt = 'Enter your sender name (eg. "Misago Forums", optional): '
    email_from = input(email_from_prompt).strip()

    env_file["MISAGO_EMAIL_PROVIDER"] = PROVIDER_SMTP
    env_file["MISAGO_EMAIL_HOST"] = email_host
    env_file["MISAGO_EMAIL_PORT"] = email_port
    env_file["MISAGO_EMAIL_USER"] = email_user
    env_file["MISAGO_EMAIL_PASSWORD"] = email_password
    env_file["MISAGO_EMAIL_USE_SSL"] = serialize_bool(email_ssl)
    env_file["MISAGO_EMAIL_USE_TLS"] = serialize_bool(email_tls)

    if email_from:
        env_file["MISAGO_DEFAULT_FROM_EMAIL"] = "%s <%s>" % (email_from,
                                                             email_address)
    else:
        env_file["MISAGO_DEFAULT_FROM_EMAIL"] = email_address
def run_sentry_wizard(env_file):
    if input_bool("Enable Sentry logging?"):
        run_dsn_wizard(env_file)
    else:
        disable_sentry(env_file)
Beispiel #22
0
def add_local_file(filename, directory, stored_contents):
  path = os.path.join(directory, filename)
  print('Stored config file %s not present locally at %s:' % (filename, path))
  print(diff_contents('', stored_contents, fromfile=path, tofile=filename))
  if input_bool('Deploy local config file %s?' % path):
    write_file(path, stored_contents)