Skip to content

Commit

Permalink
Add handling for slash at the end of paths
Browse files Browse the repository at this point in the history
- Fix python shebang
  • Loading branch information
matuzalemmuller committed Jun 30, 2022
1 parent f9ae238 commit 5011e4a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dummyfilescreator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python3
from dummyfilescreator.__main__ import main

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion dummyfilescreator/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python3
"""Author: Matuzalem (Mat) Muller.
License: GPLv3
Expand Down
24 changes: 22 additions & 2 deletions dummyfilescreator/dfc_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
"""Author: Matuzalem (Mat) Muller.
License: GPLv3
Expand Down Expand Up @@ -84,7 +85,13 @@ def __init__(self): # pylint: disable=too-many-branches
)
args = vars(parser.parse_args())

self.__folder_path = f"{args['output']}"
output = f"{args['output']}"
if output[-1] == "/":
output = output[:-1]
elif output[-1] == "\\":
output = output[:-1]
self.__folder_path = output

self.__number_files = int(args["n_files"])
self.__size_file = int(args["size"])

Expand Down Expand Up @@ -124,7 +131,12 @@ def __init__(self): # pylint: disable=too-many-branches
self.__progressbar = None

if args["log"] is not None:
self.__log_path = f"{args['log']}"
log = f"{args['log']}"
if log[-1] == "/":
log = log[:-1]
elif log[-1] == "\\":
log = log[:-1]
self.__log_path = log
else:
self.__log_path = None

Expand Down Expand Up @@ -210,3 +222,11 @@ def run(self):
except IOError as error:
print(f"CLI: Error starting FilesCreator thread: {error}")
sys.exit(1)

def main():
"""Entrypoint in case this file is executed directly."""
app = DFCCli()
app.run()

if __name__ == "__main__":
main()
18 changes: 15 additions & 3 deletions dummyfilescreator/dfc_ui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python3
"""Author: Matuzalem (Mat) Muller.
License: GPLv3
Expand Down Expand Up @@ -250,13 +250,25 @@ def __click_button_create_stop(self): # pylint: disable=too-many-branches
if self.__main_window.button_create_stop.text() == "Create":
size_file = int(self.__main_window.text_size_files.text())
chunk_size = int(self.__main_window.text_chunk_size.text())
if self.__main_window.text_path.text()[-1] == "/":
path = self.__main_window.text_path.text()[:-1]
elif self.__main_window.text_path.text()[-1] == "\\":
path = self.__main_window.text_path.text()[:-1]
else:
path = self.__main_window.text_path.text()
if self.__main_window.checkbox_savelog.isChecked():
log_path = self.__main_window.text_logfilepath.text()
if self.__main_window.text_logfilepath.text()[-1] == "/":
log_path = self.__main_window.text_logfilepath.text()[:-1]
elif self.__main_window.text_logfilepath.text()[-1] == "\\":
log_path = self.__main_window.text_logfilepath.text()[:-1]
else:
log_path = self.__main_window.text_logfilepath.text()
else:
log_path = None
try:
print(log_path)
self.__creator_thread = FilesCreator(
folder_path=self.__main_window.text_path.text(),
folder_path=path,
number_files=int(self.__main_window.text_n_files.text()),
size_file=size_file,
size_unit=self.__main_window.combo_file_unit.currentText(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/linux/build_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def is_program_installed(program_name: str):
if shutil.which(program_name):
print(f"{program_name} is installed")
return True
print(f"{program_name} not installed")
print(f"{program_name} not installed (or not added to $PATH)")

return False

Expand Down

0 comments on commit 5011e4a

Please sign in to comment.