initial
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
[main]
|
||||||
|
host = sjoelnas
|
||||||
|
user = 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
|
||||||
Executable
+74
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from simple_term_menu import TerminalMenu
|
||||||
|
|
||||||
|
inifile = 'config.ini'
|
||||||
|
|
||||||
|
def readconfig():
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(inifile)
|
||||||
|
user = config['main']['user']
|
||||||
|
host = config['main']['host']
|
||||||
|
path = config['boek']['nl']
|
||||||
|
assemble = user + "@" + host + ":" + path
|
||||||
|
return assemble
|
||||||
|
|
||||||
|
def change_config():
|
||||||
|
print("Config aangepast")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
def copy_files():
|
||||||
|
print("Files from:", os.getcwd())
|
||||||
|
files = os.listdir(".") # array of files in cwd
|
||||||
|
copy_menu = TerminalMenu(
|
||||||
|
files,
|
||||||
|
multi_select = True,
|
||||||
|
show_multi_select_hint = True,
|
||||||
|
)
|
||||||
|
copy_menu_index = copy_menu.show()
|
||||||
|
selection = copy_menu.chosen_menu_entries # array of files chosen in menu
|
||||||
|
counter = 0
|
||||||
|
for selected in selection:
|
||||||
|
cmd = "rsync"
|
||||||
|
arg = "-avz"
|
||||||
|
dest = readconfig()
|
||||||
|
process_out = subprocess.run([cmd, arg, selected, dest])
|
||||||
|
counter = counter + 1
|
||||||
|
|
||||||
|
return counter
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
main_menu_title = "Main menu for multiple file copy with rsync command\nsulzlep@gmail.com\n"
|
||||||
|
main_menu_items = ["[c] copy", "[e] edit config", "[q] quit"]
|
||||||
|
main_menu_exit = False
|
||||||
|
|
||||||
|
terminal_menu = TerminalMenu(
|
||||||
|
menu_entries = main_menu_items,
|
||||||
|
title = main_menu_title,
|
||||||
|
cycle_cursor = True,
|
||||||
|
clear_screen = True,
|
||||||
|
)
|
||||||
|
|
||||||
|
while not main_menu_exit:
|
||||||
|
menu_entry_index = terminal_menu.show()
|
||||||
|
if menu_entry_index == 0:
|
||||||
|
print("Copy files")
|
||||||
|
nr = copy_files()
|
||||||
|
print("\n\n\nThere are", nr, "files copied\n" )
|
||||||
|
input("Press enter to continue...")
|
||||||
|
elif menu_entry_index == 1:
|
||||||
|
print("Edit config")
|
||||||
|
change_config()
|
||||||
|
print (res)
|
||||||
|
input("Press enter to continue...")
|
||||||
|
elif menu_entry_index == 2:
|
||||||
|
print("Quitting")
|
||||||
|
main_menu_exit = True
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user