Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/artisan.pro
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ SOURCES = \
artisanlib/statistics.py \
artisanlib/transposer.py \
artisanlib/wheels.py \
artisanlib/command_utility.py \
const/UIconst.py \
help/alarms_help.py \
help/autosave_help.py \
Expand Down
20 changes: 12 additions & 8 deletions src/artisan.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
pass

from artisanlib import main
from artisanlib import main, command_utility
#import numpy # @UnusedImport # what this for!?
from multiprocessing import freeze_support

Expand All @@ -80,14 +81,17 @@
del executable

if __name__ == '__main__':
freeze_support()
if os.environ.get('TRAVIS'):
# Hack to exit inside Travis CI
# Ideally we would use pytest-qt.
import threading
t = threading.Timer(30, lambda: os._exit(0))
t.start()
main.main()

# Manange Commands that does not need to start the whole Application
if command_utility.handleCommands() == True:
freeze_support()
if os.environ.get('TRAVIS'):
# Hack to exit inside Travis CI
# Ideally we would use pytest-qt.
import threading
t = threading.Timer(30, lambda: os._exit(0))
t.start()
main.main()


# EOF
59 changes: 59 additions & 0 deletions src/artisanlib/command_utility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3

# ABOUT
# Handeling of Commandline Utility Functions

# LICENSE
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later versison. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.

# AUTHOR
# FilePhil, 2020

from artisanlib import __version__
import sys

def handleCommands():
""" Handles incoming commands and decides on an action.

args -- given command line arguments
return -- if the action requires the application, return true
"""

for arg in sys.argv:

if arg in ('-v', '--Version'):
print ('Artisan Verison {}'.format(__version__))

return False

if arg in ('-h', '--Help'):
# To write a text that is not indented
# the text must be written like this
helpText ="""
Artisan Verison {}

Usage:
artsian
artsian [options] [path ...]


One path to a file may be specified. If there is an
existing Artisan window the path will be opened in the
viewer mode.

Options:
-h, --help Show help
-v, --Version Show version number
"""

print(helpText)
return False

return True