Added ask user how many days to trigger server purge

This commit is contained in:
spla 2022-03-02 13:11:01 +01:00
pare d46ede3bd5
commit 13fd0434de
S'han modificat 2 arxius amb 9 adicions i 2 eliminacions

Veure arxiu

@ -64,7 +64,7 @@ def dead():
cur = conn.cursor()
cur.execute("select server from peers where downs >= '7'")
cur.execute("select server from peers where downs >=(%s)", (purge_days,))
rows = cur.fetchall()
@ -280,6 +280,7 @@ if __name__ == '__main__':
config_filepath = "config/config.txt"
mastodon_hostname = get_parameter("mastodon_hostname", config_filepath)
mastodon_full_path = get_parameter("mastodon_full_path", config_filepath)
purge_days = get_parameter("purge_days", config_filepath)
cleanserver_db, cleanserver_db_user = dbconfig()

Veure arxiu

@ -20,6 +20,8 @@ def write_config():
print(f"adding parameter 'mastodon_hostname' to {config_filepath}")
the_file.write('mastodon_full_path: \n')
print(f"adding parameter 'mastodon_full_path' to {config_filepath}")
the_file.write('purge_days: \n')
print(f"adding parameter 'purge_days' to {config_filepath}")
def read_config_line():
@ -28,6 +30,7 @@ def read_config_line():
line = fp.readline()
modify_file(config_filepath, "mastodon_hostname: ", value=hostname)
modify_file(config_filepath, "mastodon_full_path: ", value=full_path)
modify_file(config_filepath, "purge_days: ", value=purge_days)
def modify_file(file_name,pattern,value=""):
@ -63,10 +66,12 @@ def get_parameter( parameter, config_filepath ):
write_config()
global hostname, full_path
global hostname, full_path, purge_days
hostname = input("Enter Mastodon hostname: ")
full_path = input("Enter Mastodon's full path dir: ")
purge_days = int(input("Enter days to trigger server purge (default 7): ") or "7")
purge_days = str(purge_days)
read_config_line()
@ -82,3 +87,4 @@ if __name__ == '__main__':
config_filepath = "config/config.txt"
mastodon_hostname = get_parameter("mastodon_hostname", config_filepath)
mastodon_full_path = get_parameter("mastodon_full_path", config_filepath)
purge_days = get_parameter("purge_days", config_filepath)