Skip to content

Commit

Permalink
Fixed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
pdz10001 committed Oct 17, 2017
2 parents ced0a0a + 9ac0bd0 commit 724099e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ target/
*.idea

#Subdivision Log Generator log file
logs/
logs/*
13 changes: 9 additions & 4 deletions cli_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
"""
import argparse
import cmd
import logging.config
import os
import sys

from user_interface.curve_parser import parse_curve_file
from logger import get_logger


class CliApplication(cmd.Cmd):

def __init__(self, application_path=None, application_name="generator", args=None):
self.logger = logging.getLogger(__name__)
self.logger = get_logger(__name__)
self.curve_paths = os.path.join(application_path, "test_curves")
self.arguments = args
self.parse_cmd_args(self.arguments)
Expand All @@ -25,8 +26,11 @@ def parse_cmd_args(self, args):
if os.path.exists(args.generate_m_value):
self.generate_m_value(args.generate_m_value)
else:
self.generate_m_value(os.path.join(self.curve_paths, args.generate_m_value))

curve_path = os.path.join(self.curve_paths, args.generate_m_value)
if os.path.exists(curve_path):
self.generate_m_value(curve_path)
else:
self.logger.info("The curve file doesn't exist. Please choose an appropriate file.")
else:
raise Exception("There were no arguments when running the application")

Expand All @@ -48,6 +52,7 @@ def main():
stick knot's Bezier cure to match the stick knot", default=None, action="store")
arguments = argument_parser.parse_args()

get_logger().debug("Subdivision-Generator Starting Up")
application = CliApplication(application_path, application_name, arguments)


Expand Down
11 changes: 10 additions & 1 deletion logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ def get_logger(classname=None):
if not os.path.exists(log_dir):
os.makedirs(log_dir)

logging.basicConfig(filename="logs/generator_log.txt", level="DEBUG")
root = logging.getLogger()
if root.handlers:
for handler in root.handlers:
root.removeHandler(handler)

logging.basicConfig(format='%(asctime)s: %(filename)s: %(funcName)s: %(levelname)s:\t %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', filename="logs/generator_log.txt")

if classname is None:
classname = "Subdivision Generator"

logger = logging.getLogger(classname)
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler())

return logging.getLogger(classname)
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)"
"$SCRIPT_DIR/user_interface/cli_application.py" $*
"$SCRIPT_DIR/cli_application.py" $*

0 comments on commit 724099e

Please sign in to comment.