Working on changing ini file
This commit is contained in:
+4
-15
@@ -1,20 +1,9 @@
|
|||||||
[main]
|
[main]
|
||||||
host = sjoelnas
|
desthost = sjoelnas
|
||||||
user = admin
|
destuser = admin
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
path = "."
|
path = "."
|
||||||
|
|
||||||
[muziek]
|
[destination]
|
||||||
albums = /share/Multimedia/Muziek/Albums3
|
path = /share/Download/Boeken
|
||||||
verzamel = /share/Multimedia/Muziek/Verzamelalbum
|
|
||||||
|
|
||||||
[film]
|
|
||||||
aktie = /share/Multimedia/Films/Aktie
|
|
||||||
drama = /share/Multimedia/Films/Drama
|
|
||||||
klassieker = /share/Multimedia/Films/Klassieker
|
|
||||||
|
|
||||||
[boek]
|
|
||||||
nl = /share/Download/Boeken
|
|
||||||
en = "/share/Download/engelse boeken"
|
|
||||||
magazine = /Download/Magazines
|
|
||||||
|
|||||||
+12
-9
@@ -11,19 +11,22 @@ inifile = 'config.ini'
|
|||||||
def readconfig():
|
def readconfig():
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(inifile)
|
config.read(inifile)
|
||||||
user = config['main']['user']
|
user = config['main']['destuser']
|
||||||
host = config['main']['host']
|
host = config['main']['desthost']
|
||||||
path = config['boek']['nl']
|
path = config['destination']['path']
|
||||||
assemble = user + "@" + host + ":" + path
|
assemble = user + "@" + host + ":" + path
|
||||||
return assemble
|
return assemble
|
||||||
|
|
||||||
def change_config():
|
def change_config():
|
||||||
print("Config aangepast")
|
with open(inifile, "r") as f:
|
||||||
exit()
|
content = f.read()
|
||||||
|
print(content)
|
||||||
|
return
|
||||||
|
|
||||||
def copy_files():
|
def copy_files():
|
||||||
print("Files from:", os.getcwd())
|
print("Files from:", os.getcwd())
|
||||||
files = os.listdir(".") # array of files in cwd
|
files = os.listdir(".") # array of files in cwd
|
||||||
|
files.append("Select None and Return")
|
||||||
copy_menu = TerminalMenu(
|
copy_menu = TerminalMenu(
|
||||||
files,
|
files,
|
||||||
multi_select = True,
|
multi_select = True,
|
||||||
@@ -33,12 +36,13 @@ def copy_files():
|
|||||||
selection = copy_menu.chosen_menu_entries # array of files chosen in menu
|
selection = copy_menu.chosen_menu_entries # array of files chosen in menu
|
||||||
counter = 0
|
counter = 0
|
||||||
for selected in selection:
|
for selected in selection:
|
||||||
|
if selected == "Select None and Return":
|
||||||
|
return counter
|
||||||
cmd = "rsync"
|
cmd = "rsync"
|
||||||
arg = "-avz"
|
arg = "-avz"
|
||||||
dest = readconfig()
|
dest = readconfig()
|
||||||
process_out = subprocess.run([cmd, arg, selected, dest])
|
process_out = subprocess.run([cmd, arg, selected, dest])
|
||||||
counter = counter + 1
|
counter += 1
|
||||||
|
|
||||||
return counter
|
return counter
|
||||||
|
|
||||||
|
|
||||||
@@ -62,9 +66,8 @@ def main():
|
|||||||
print("\n\n\nThere are", nr, "files copied\n" )
|
print("\n\n\nThere are", nr, "files copied\n" )
|
||||||
input("Press enter to continue...")
|
input("Press enter to continue...")
|
||||||
elif menu_entry_index == 1:
|
elif menu_entry_index == 1:
|
||||||
print("Edit config")
|
print("Show config from:", inifile, "\n")
|
||||||
change_config()
|
change_config()
|
||||||
print (res)
|
|
||||||
input("Press enter to continue...")
|
input("Press enter to continue...")
|
||||||
elif menu_entry_index == 2:
|
elif menu_entry_index == 2:
|
||||||
print("Quitting")
|
print("Quitting")
|
||||||
|
|||||||
Reference in New Issue
Block a user