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