mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-06 00:57:14 -04:00
Use 'if __name__ == "__main__":' convention
This commit is contained in:
@@ -483,17 +483,16 @@ def remove_data(): # deletes an entry from the server and flags it for local de
|
|||||||
f"; sshypRemote.delete(\"'\"{_entry_name}\"'\")'\"")
|
f"; sshypRemote.delete(\"'\"{_entry_name}\"'\")'\"")
|
||||||
|
|
||||||
|
|
||||||
# program start sequence
|
if __name__ == "__main__":
|
||||||
|
# retrieve typed argument
|
||||||
# retrieve typed argument
|
argument_list, argument = argv, ''
|
||||||
argument_list, argument = argv, ''
|
argument_list.pop(0)
|
||||||
argument_list.pop(0)
|
for _argument in argument_list:
|
||||||
for _argument in argument_list:
|
|
||||||
argument += _argument + ' '
|
argument += _argument + ' '
|
||||||
argument = argument[:-1]
|
argument = argument[:-1]
|
||||||
|
|
||||||
# import saved userdata
|
# import saved userdata
|
||||||
if argument != 'tweak':
|
if argument != 'tweak':
|
||||||
device_type = ''
|
device_type = ''
|
||||||
tmp_dir = path.expanduser('~/.config/sshyp/tmp/')
|
tmp_dir = path.expanduser('~/.config/sshyp/tmp/')
|
||||||
try:
|
try:
|
||||||
@@ -513,7 +512,7 @@ if argument != 'tweak':
|
|||||||
print("Not all necessary configuration files are present. Please run 'sshyp tweak'!")
|
print("Not all necessary configuration files are present. Please run 'sshyp tweak'!")
|
||||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
tweak()
|
tweak()
|
||||||
s_exit()
|
s_exit()
|
||||||
@@ -521,72 +520,72 @@ else:
|
|||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
|
|
||||||
# run function based on argument
|
# run function based on argument
|
||||||
error = 0 # create an error flag to determine if syncing should occur at end
|
error = 0 # create an error flag to determine if syncing should occur at end
|
||||||
if argument.startswith('/'):
|
if argument.startswith('/'):
|
||||||
read_shortcut()
|
read_shortcut()
|
||||||
elif argument == '':
|
elif argument == '':
|
||||||
try:
|
try:
|
||||||
no_arg()
|
no_arg()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'help' or argument == '--help' or argument == '-h' or argument == 'license' or argument == 'version' \
|
elif argument == 'help' or argument == '--help' or argument == '-h' or argument == 'license' or argument == 'version' \
|
||||||
or argument == '-v' or argument == 'add' or argument == 'edit' or argument == 'copy':
|
or argument == '-v' or argument == 'add' or argument == 'edit' or argument == 'copy':
|
||||||
print_info()
|
print_info()
|
||||||
elif argument == 'add note' or argument == 'add -n' or argument == 'add password' or argument == 'add -p':
|
elif argument == 'add note' or argument == 'add -n' or argument == 'add password' or argument == 'add -p':
|
||||||
try:
|
try:
|
||||||
add_entry()
|
add_entry()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'add folder' or argument == 'add -f':
|
elif argument == 'add folder' or argument == 'add -f':
|
||||||
try:
|
try:
|
||||||
add_folder()
|
add_folder()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r':
|
elif argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r':
|
||||||
try:
|
try:
|
||||||
rename()
|
rename()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'edit username' or argument == 'edit -u' or argument == 'edit password' or argument == 'edit -p' or \
|
elif argument == 'edit username' or argument == 'edit -u' or argument == 'edit password' or argument == 'edit -p' or \
|
||||||
argument == 'edit url' or argument == 'edit -l' or argument == 'edit note' or argument == 'edit -n':
|
argument == 'edit url' or argument == 'edit -l' or argument == 'edit note' or argument == 'edit -n':
|
||||||
try:
|
try:
|
||||||
edit()
|
edit()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'gen' or argument == 'gen update' or argument == 'gen -u':
|
elif argument == 'gen' or argument == 'gen update' or argument == 'gen -u':
|
||||||
try:
|
try:
|
||||||
gen()
|
gen()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'copy username' or argument == 'copy -u' or argument == 'copy password' or argument == 'copy -p' or \
|
elif argument == 'copy username' or argument == 'copy -u' or argument == 'copy password' or argument == 'copy -p' or \
|
||||||
argument == 'copy url' or argument == 'copy -l' or argument == 'copy note' or argument == 'copy -n':
|
argument == 'copy url' or argument == 'copy -l' or argument == 'copy note' or argument == 'copy -n':
|
||||||
try:
|
try:
|
||||||
copy_data()
|
copy_data()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'shear' or argument == '-rm':
|
elif argument == 'shear' or argument == '-rm':
|
||||||
try:
|
try:
|
||||||
remove_data()
|
remove_data()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n')
|
print('\n')
|
||||||
s_exit()
|
s_exit()
|
||||||
elif argument == 'sync' or argument == '-s':
|
elif argument == 'sync' or argument == '-s':
|
||||||
sync()
|
sync()
|
||||||
else:
|
else:
|
||||||
error = 1 # set error flag to 1 to stop syncing
|
error = 1 # set error flag to 1 to stop syncing
|
||||||
print("\nArgument error! Please run 'sshyp help' for a list of usable commands.\n")
|
print("\nArgument error! Please run 'sshyp help' for a list of usable commands.\n")
|
||||||
s_exit()
|
s_exit()
|
||||||
|
|
||||||
# sync at end of program if any changes were made
|
# sync at end of program if any changes were made
|
||||||
if argument != '' and argument != 'help' and argument != '--help' and argument != '-h' and argument != 'license' and \
|
if argument != '' and argument != 'help' and argument != '--help' and argument != '-h' and argument != 'license' and \
|
||||||
argument != 'add' and argument != 'sync' and argument != 'edit' and argument != 'copy username' and argument \
|
argument != 'add' and argument != 'sync' and argument != 'edit' and argument != 'copy username' and argument \
|
||||||
!= 'copy -u' and argument != 'copy password' and argument != 'copy -p' and argument != 'copy url' and argument \
|
!= 'copy -u' and argument != 'copy password' and argument != 'copy -p' and argument != 'copy url' and argument \
|
||||||
!= 'copy -l' and argument != 'copy note' and argument != 'copy -n' and argument != 'copy' and argument \
|
!= 'copy -l' and argument != 'copy note' and argument != 'copy -n' and argument != 'copy' and argument \
|
||||||
|
|||||||
Reference in New Issue
Block a user