added and completed cli functionality for use

This commit is contained in:
Xevion
2019-11-03 17:17:35 -06:00
parent 822351652d
commit 90569c8f04
5 changed files with 39 additions and 31 deletions

View File

@@ -9,9 +9,8 @@ logging.basicConfig(level=logging.INFO)
log = logging.getLogger('init')
log.info('Progressbar/Logging ready.')
# Path Constants
ROOT = os.path.dirname(os.path.realpath(__file__))
ROOT = os.getcwd()
INPUT_PATH = ROOT
TEMP_PATH = os.path.join(ROOT, 'temp')
OUTPUT_PATH = os.path.join(ROOT, 'output')

View File

@@ -1,13 +1,20 @@
import sys
import os
import logging
from .app import main
from . import INPUT_PATH, OUTPUT_PATH
# Ensure that 'input' and 'output' directories are created
if not os.path.exists(INPUT_PATH):
logging.fatal('Input directory did not exist, creating and quitting.')
os.makedirs(INPUT_PATH)
# if not os.path.exists(INPUT_PATH):
# logging.fatal('Input directory did not exist, creating and quitting.')
# os.makedirs(INPUT_PATH)
if not os.path.exists(OUTPUT_PATH):
logging.info('Output directory did not exist. Creating...')
os.makedirs(OUTPUT_PATH)
# if not os.path.exists(OUTPUT_PATH):
# logging.info('Output directory did not exist. Creating...')
# os.makedirs(OUTPUT_PATH)
log = logging.getLogger('main')
if __name__ == "__main__":
main()

12
package/cli.py Normal file
View File

@@ -0,0 +1,12 @@
import logging
import click
import os
from .app import run
from . import ROOT, INPUT_PATH, OUTPUT_PATH, TEMP_PATH
@click.command()
def cli():
print('\n'.join([os.getcwd(), ROOT, INPUT_PATH, OUTPUT_PATH, TEMP_PATH]))
print('Executing phototag service')
run()
print('Phototag service executed')

View File

@@ -1,20 +0,0 @@
import sys
import os
import logging
import click
from package import app
log = logging.getLogger('main')
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = os.path.join(
sys.path[0], 'package', 'key', 'photo_tagging_service.json')
@click.command()
def cli():
log.info('Executing package...')
sys.exit(app.run())
if __name__ == "__main__":
main()

View File

@@ -3,7 +3,17 @@ import os
import io
from setuptools import find_packages, setup
DEPENDENCIES = ['Click']
DEPENDENCIES = [
'Click',
'rawpy',
'imageio',
'progressbar2',
'iptcinfo3',
'google-api-python-client',
'google-cloud',
'google-cloud-vision',
'Pillow'
]
EXCLUDE_FROM_PACKAGES = []
CURDIR = sys.path[0]
@@ -25,7 +35,7 @@ setup(
scripts=[],
entry_points='''
[console_scripts]
phototag=phototag.phototag:cli
phototag=package.cli:cli
''',
zip_safe=False,
install_requires=DEPENDENCIES,
@@ -37,4 +47,4 @@ setup(
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
)
)