Fixes
This commit is contained in:
parent
7a0484b0f0
commit
715b09859d
|
@ -371,7 +371,7 @@ def checkFile(
|
|||
.format(**craptool.text_colors)\
|
||||
%( err_key, parent_path, entry_name ))
|
||||
if craptool.more_output is True:
|
||||
print("%s craptool doesn't have permissions to read from this file" %(spaces))
|
||||
print("%s %s doesn't have permissions to read from this file" %(craptool.name,spaces))
|
||||
print("%s please make the file readable and retry" %(spaces))
|
||||
print()
|
||||
if w is True\
|
||||
|
@ -381,7 +381,7 @@ def checkFile(
|
|||
.format(**craptool.text_colors)\
|
||||
%( err_key, parent_path, entry_name ))
|
||||
if craptool.more_output is True:
|
||||
print("%s craptool doesn't have permissions to write in this file" %(spaces))
|
||||
print("%s %s doesn't have permissions to write in this file" %(craptool.name,spaces))
|
||||
print("%s please make the file writable and retry" %(spaces))
|
||||
print()
|
||||
else:
|
||||
|
@ -461,7 +461,7 @@ def checkFile(
|
|||
pass
|
||||
else:
|
||||
# ..but should have existed
|
||||
if craptool.name != "craptool":
|
||||
if craptool.name != "crapset":
|
||||
# print an error message
|
||||
failed()
|
||||
print("\n{err}Error{white}[{grey}%s{white}]{red}>{default} the given path does not exist: %s\n"\
|
||||
|
|
|
@ -31,6 +31,8 @@ class Craplog(object):
|
|||
"""
|
||||
Craplog's initializer
|
||||
"""
|
||||
# craptool name
|
||||
self.name = "craplog"
|
||||
# variables from args
|
||||
self.use_configs: bool
|
||||
self.use_arguments: bool
|
||||
|
|
|
@ -3,7 +3,7 @@ from sys import argv
|
|||
from sys import path as libpath
|
||||
|
||||
from time import sleep
|
||||
from os.path import abspath
|
||||
from os.path import abspath, exists
|
||||
|
||||
crappath = abspath(__file__)
|
||||
crappath = crappath[:crappath.rfind('/')]
|
||||
|
@ -23,6 +23,8 @@ class Crapset():
|
|||
"""
|
||||
def __init__(self, args:list ):
|
||||
""" Initialize Crapset """
|
||||
# craptool name
|
||||
self.name = "crapset"
|
||||
# get the path to the configuration files
|
||||
crappath = abspath(__file__)
|
||||
crappath = crappath[:crappath.rfind('/')]
|
||||
|
@ -92,42 +94,42 @@ class Crapset():
|
|||
"""
|
||||
Read the saved configuration
|
||||
"""
|
||||
if os.path.exists( self.file_path ) is False:
|
||||
if exists( self.file_path ) is False:
|
||||
# leave this normal yellow, it's secondary and doesn't need a real attention
|
||||
if self.less_output is False:
|
||||
print("\n{warn}Warning{white}[{grey}configs{white}]{warn}>{default} {yellow}configurations file not found\n"\
|
||||
.format(**self.text_colors))
|
||||
sleep(1)
|
||||
else:
|
||||
with open(self.file_path,'r') as f:
|
||||
tmp = f.read().strip().split('\n')
|
||||
configs = []
|
||||
for f in tmp:
|
||||
f = f.strip()
|
||||
if f == ""\
|
||||
or f[0] == "#":
|
||||
continue
|
||||
configs.append(f)
|
||||
# check the length
|
||||
if len(configs) != 5:
|
||||
print("\n{err}Error{white}[{grey}crapset.crapconf{white}]{red}>{default} invalid number of lines: {rose}%s{default}"\
|
||||
.format(**self.text_colors)\
|
||||
%( len(configs) ))
|
||||
if self.less_output is False:
|
||||
print("""
|
||||
if you have manually edited the configurations file, please un-do the changes
|
||||
else, please report this issue""")
|
||||
print("\n{err}CRAPSET ABORTED{default}\n"\
|
||||
.format(**self.text_colors))
|
||||
exit()
|
||||
# apply the configs
|
||||
self.use_configs = bool(int(configs[0]))
|
||||
if self.use_configs is True:
|
||||
self.use_arguments: bool(int(configs[1]))
|
||||
self.less_output: bool(int(configs[2]))
|
||||
self.more_output: bool(int(configs[3]))
|
||||
self.use_colors: bool(int(configs[4]))
|
||||
self.initMessages()
|
||||
with open(self.file_path,'r') as f:
|
||||
tmp = f.read().strip().split('\n')
|
||||
configs = []
|
||||
for f in tmp:
|
||||
f = f.strip()
|
||||
if f == ""\
|
||||
or f[0] == "#":
|
||||
continue
|
||||
configs.append(f)
|
||||
# check the length
|
||||
if len(configs) != 5:
|
||||
print("\n{err}Error{white}[{grey}crapset.crapconf{white}]{red}>{default} invalid number of lines: {rose}%s{default}"\
|
||||
.format(**self.text_colors)\
|
||||
%( len(configs) ))
|
||||
if self.less_output is False:
|
||||
print("""
|
||||
if you have manually edited the configurations file, please un-do the changes
|
||||
else, please report this issue""")
|
||||
print("\n{err}CRAPSET ABORTED{default}\n"\
|
||||
.format(**self.text_colors))
|
||||
exit()
|
||||
# apply the configs
|
||||
self.use_configs = bool(int(configs[0]))
|
||||
if self.use_configs is True:
|
||||
self.use_arguments: bool(int(configs[1]))
|
||||
self.less_output: bool(int(configs[2]))
|
||||
self.more_output: bool(int(configs[3]))
|
||||
self.use_colors: bool(int(configs[4]))
|
||||
self.initMessages()
|
||||
|
||||
|
||||
|
||||
|
@ -245,6 +247,8 @@ class Crapset():
|
|||
"""
|
||||
Print the abortion message and exit
|
||||
"""
|
||||
if self.less_output is False:
|
||||
print()
|
||||
print("\n{err}CRAPSET ABORTED{default}"\
|
||||
.format(**self.text_colors))
|
||||
if self.less_output is False:
|
||||
|
|
|
@ -7,7 +7,7 @@ def versionCheck( crapup:object ):
|
|||
Manages the request
|
||||
"""
|
||||
# version check url
|
||||
url = "https://git.disroot.org/elB4RTO/craplog-CLI/blob/main/version_check"
|
||||
url = "https://github.com/elB4RTO/craplog-CLI/blob/main/version_check"
|
||||
# additional headers
|
||||
headers = { 'Connection':'close' }
|
||||
# timeout for the connection to be established (in seconds)
|
||||
|
@ -37,7 +37,7 @@ def versionCheck( crapup:object ):
|
|||
try:
|
||||
# get the new version string and convert it to number
|
||||
new_version = html[
|
||||
(pos+len(version_mark)+1)
|
||||
(pos+len(version_mark))
|
||||
:
|
||||
html.find(version_mark,(pos+len(version_mark)+1)) ]
|
||||
new_version = float( new_version )
|
||||
|
|
|
@ -223,7 +223,7 @@ def gitPull( crapup:object ):
|
|||
if crapup.more_output is True:
|
||||
print("\n{rose}%s{default}"\
|
||||
.format(**crapup.text_colors)\
|
||||
%( command.stderr.decode.strip('\n') ))
|
||||
%( command.stderr.decode().strip('\n') ))
|
||||
print()
|
||||
crapup.exitAborted()
|
||||
# restore the personal gitignore file
|
||||
|
|
|
@ -3,7 +3,7 @@ from sys import argv
|
|||
from sys import path as libpath
|
||||
|
||||
from time import sleep
|
||||
from os.path import abspath
|
||||
from os.path import abspath, exists
|
||||
|
||||
crappath = abspath(__file__)
|
||||
crappath = crappath[:crappath.rfind('/')]
|
||||
|
@ -20,6 +20,8 @@ class Crapup():
|
|||
Craplog's updater
|
||||
"""
|
||||
def __init__(self, args:list ):
|
||||
# craptool name
|
||||
self.name = "crapup"
|
||||
# declare variables
|
||||
self.use_configs: bool
|
||||
self.use_arguments: bool
|
||||
|
@ -125,7 +127,7 @@ class Crapup():
|
|||
crappath = crappath[:crappath.rfind('/')]
|
||||
self.crappath = crappath[:crappath.rfind('/')]
|
||||
path = "%s/crapconfs/crapup.crapconf" %(self.crappath)
|
||||
if os.path.exists( path ) is False:
|
||||
if exists( path ) is False:
|
||||
# leave this normal yellow, it's secondary and doesn't need a real attention
|
||||
if self.less_output is False:
|
||||
print("\n{warn}Warning{white}[{grey}configs{white}]{warn}>{default} {yellow}configurations file not found\n"\
|
||||
|
@ -271,6 +273,8 @@ class Crapup():
|
|||
"""
|
||||
Print the abortion message and exit
|
||||
"""
|
||||
if self.less_output is False:
|
||||
print()
|
||||
print("{err}CRAPUP ABORTED{default}"\
|
||||
.format(**self.text_colors))
|
||||
if self.less_output is False:
|
||||
|
|
|
@ -107,6 +107,7 @@ class Tree( UIobj ):
|
|||
trunk = "%s/crapstats" %( self.roots )
|
||||
trunk_len = len(trunk)+1
|
||||
for path,dirs,files in growing( trunk ):
|
||||
dirs2del = []
|
||||
# step in the correct position
|
||||
branch = self.tree
|
||||
if len(path) > trunk_len:
|
||||
|
@ -119,9 +120,11 @@ class Tree( UIobj ):
|
|||
for dir_name in dirs:
|
||||
if dir_name.startswith('.')\
|
||||
or dir_name in ["CVS", "backups"]:
|
||||
dirs.remove( dir_name )
|
||||
dirs2del.append( dir_name )
|
||||
continue
|
||||
branch.update({ dir_name : {} })
|
||||
for dir_name in dirs2del:
|
||||
dirs.remove( dir_name )
|
||||
# append crapstat files as paths
|
||||
for file_name in files:
|
||||
if not file_name.startswith('.')\
|
||||
|
|
|
@ -6,7 +6,7 @@ from time import sleep
|
|||
from sys import argv
|
||||
from sys import path as libpath
|
||||
|
||||
from os.path import abspath
|
||||
from os.path import abspath, exists
|
||||
|
||||
crappath = abspath(__file__)
|
||||
crappath = crappath[:crappath.rfind('/')]
|
||||
|
@ -68,39 +68,39 @@ def initCrapview( args ) -> bool :
|
|||
crappath = abspath(__file__)
|
||||
crappath = crappath[:crappath.rfind('/')]
|
||||
path = "%s/crapconfs/crapview.crapconf" %(crappath[:crappath.rfind('/')])
|
||||
if os.path.exists( path ) is False:
|
||||
if exists( path ) is False:
|
||||
# leave this normal yellow, it's secondary and doesn't need a real attention
|
||||
if self.less_output is False:
|
||||
print("\n{warn}Warning{white}[{grey}configs{white}]{warn}>{default} {yellow}configurations file not found\n"\
|
||||
.format(**self.text_colors))
|
||||
sleep(2)
|
||||
else:
|
||||
with open(path,'r') as f:
|
||||
tmp = f.read().strip().split('\n')
|
||||
configs = []
|
||||
for f in tmp:
|
||||
f = f.strip()
|
||||
if f == ""\
|
||||
or f[0] == "#":
|
||||
continue
|
||||
configs.append(f)
|
||||
# check the length
|
||||
if len(configs) != 3:
|
||||
print("\n{err}Error{white}[{grey}configs{white}]{red}>{default} invalid number of lines: {rose}%s{default}"\
|
||||
.format(**text_colors)\
|
||||
%( len(configs) ))
|
||||
print("""
|
||||
if you have manually edited the configurations file, please un-do the changes
|
||||
else, please report this issue""")
|
||||
print("\n{err}CRAPVIEW ABORTED{default}\n"\
|
||||
.format(**text_colors))
|
||||
exit()
|
||||
# apply the configs
|
||||
use_configs = bool(int(configs[0]))
|
||||
if use_configs is True:
|
||||
use_arguments = bool(int(configs[1]))
|
||||
use_colors = bool(int(configs[2]))
|
||||
initMessages()
|
||||
with open(path,'r') as f:
|
||||
tmp = f.read().strip().split('\n')
|
||||
configs = []
|
||||
for f in tmp:
|
||||
f = f.strip()
|
||||
if f == ""\
|
||||
or f[0] == "#":
|
||||
continue
|
||||
configs.append(f)
|
||||
# check the length
|
||||
if len(configs) != 3:
|
||||
print("\n{err}Error{white}[{grey}configs{white}]{red}>{default} invalid number of lines: {rose}%s{default}"\
|
||||
.format(**text_colors)\
|
||||
%( len(configs) ))
|
||||
print("""
|
||||
if you have manually edited the configurations file, please un-do the changes
|
||||
else, please report this issue""")
|
||||
print("\n{err}CRAPVIEW ABORTED{default}\n"\
|
||||
.format(**text_colors))
|
||||
exit()
|
||||
# apply the configs
|
||||
use_configs = bool(int(configs[0]))
|
||||
if use_configs is True:
|
||||
use_arguments = bool(int(configs[1]))
|
||||
use_colors = bool(int(configs[2]))
|
||||
initMessages()
|
||||
|
||||
if use_arguments is True:
|
||||
# parse args
|
||||
|
|
|
@ -158,7 +158,7 @@ do
|
|||
then
|
||||
dst="$(echo $dst | cut -d/ -f2)/"
|
||||
fi
|
||||
mv "$crapdir/$src" "$inst_path/$dst"
|
||||
cp "$crapdir/$src" "$inst_path/$dst"
|
||||
wait
|
||||
done
|
||||
|
||||
|
|
|
@ -20,4 +20,4 @@
|
|||
|
||||
# USE COLORS TO PRINT THE OUTPUT MESSAGES
|
||||
1
|
||||
0
|
||||
|
||||
|
|
Loading…
Reference in New Issue