|
|
@ -43,13 +43,10 @@ def run(): |
|
|
|
# subparser command: `punch` |
|
|
|
# subparser command: `punch` |
|
|
|
parser_punch = subparsers.add_parser("punch", |
|
|
|
parser_punch = subparsers.add_parser("punch", |
|
|
|
help="use this command to punch in, punch out, or create break entries") |
|
|
|
help="use this command to punch in, punch out, or create break entries") |
|
|
|
parser_punch.add_argument("-t", |
|
|
|
parser_punch.add_argument("-t", help=f"type of time entry; this can be {', '.join(PUNCH_COMMANDS)}", |
|
|
|
help=f"type of time entry; this can be {', '.join(PUNCH_COMMANDS)}", |
|
|
|
default="punch_in", choices=PUNCH_COMMANDS) |
|
|
|
default="punch_in", |
|
|
|
parser_punch.add_argument("-s", help=f"timestamp in format `{DateFormats.SIMPLE_DATETIME.evalue}`, " |
|
|
|
choices=PUNCH_COMMANDS) |
|
|
|
f"`{DateFormats.SIMPLE_TIME.evalue}` or `now`", default="now") |
|
|
|
parser_punch.add_argument("-s", |
|
|
|
|
|
|
|
help=f"timestamp in format `{DateFormats.SIMPLE_DATETIME.evalue}`, " |
|
|
|
|
|
|
|
f"`{DateFormats.SIMPLE_TIME.evalue}` or `now`", default="now") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# subparser command: `smart-punch` |
|
|
|
# subparser command: `smart-punch` |
|
|
|
parser_smart_punch = subparsers.add_parser("smart-punch", |
|
|
|
parser_smart_punch = subparsers.add_parser("smart-punch", |
|
|
@ -69,8 +66,8 @@ def run(): |
|
|
|
config.read(args.c) |
|
|
|
config.read(args.c) |
|
|
|
|
|
|
|
|
|
|
|
if args.use_system_ca_store or config.get(section="general", option="use_system_ca_store", fallback="no") == "yes": |
|
|
|
if args.use_system_ca_store or config.get(section="general", option="use_system_ca_store", fallback="no") == "yes": |
|
|
|
os.environ["REQUESTS_CA_BUNDLE"] = config["general"]["system_ca_store"] \ |
|
|
|
os.environ["REQUESTS_CA_BUNDLE"] = config["general"]["system_ca_store"] if "system_ca_store" in config[ |
|
|
|
if "system_ca_store" in config["general"] else "/etc/ssl/certs/ca-certificates.crt" |
|
|
|
"general"] else "/etc/ssl/certs/ca-certificates.crt" |
|
|
|
|
|
|
|
|
|
|
|
user = args.u if args.u is not None else config.get(section="general", option="mobatime_user", fallback=None) |
|
|
|
user = args.u if args.u is not None else config.get(section="general", option="mobatime_user", fallback=None) |
|
|
|
if user is None: |
|
|
|
if user is None: |
|
|
@ -88,11 +85,9 @@ def run(): |
|
|
|
punch_datetime = datetime.datetime.now() |
|
|
|
punch_datetime = datetime.datetime.now() |
|
|
|
else: |
|
|
|
else: |
|
|
|
punch_datetime = parse_user_time_input(args.s) |
|
|
|
punch_datetime = parse_user_time_input(args.s) |
|
|
|
logger.info("running `{}` with date `{}` and time `{}`".format( |
|
|
|
logger.info("running `{}` with date `{}` and time `{}`".format(args.t, |
|
|
|
args.t, |
|
|
|
|
|
|
|
punch_datetime.strftime(DateFormats.SIMPLE_DATE.value), |
|
|
|
punch_datetime.strftime(DateFormats.SIMPLE_DATE.value), |
|
|
|
punch_datetime.strftime(DateFormats.SIMPLE_TIME.value), |
|
|
|
punch_datetime.strftime(DateFormats.SIMPLE_TIME.value), )) |
|
|
|
)) |
|
|
|
|
|
|
|
getattr(tb, args.t)(punch_datetime) |
|
|
|
getattr(tb, args.t)(punch_datetime) |
|
|
|
elif args.subparser_name == "smart-punch": |
|
|
|
elif args.subparser_name == "smart-punch": |
|
|
|
if args.s == "now": |
|
|
|
if args.s == "now": |
|
|
@ -117,9 +112,8 @@ def run(): |
|
|
|
from timebot.gui import MainWindow |
|
|
|
from timebot.gui import MainWindow |
|
|
|
signal.signal(signal.SIGINT, lambda *_args: QApplication.quit()) |
|
|
|
signal.signal(signal.SIGINT, lambda *_args: QApplication.quit()) |
|
|
|
app = QApplication(sys.argv) |
|
|
|
app = QApplication(sys.argv) |
|
|
|
main_window = MainWindow(timebot=tb, refresh_interval=config.get(section="gui", |
|
|
|
main_window = MainWindow(timebot=tb, |
|
|
|
option="refresh_interval", |
|
|
|
refresh_interval=config.get(section="gui", option="refresh_interval", fallback="1m")) |
|
|
|
fallback="1m")) |
|
|
|
|
|
|
|
main_window.show() |
|
|
|
main_window.show() |
|
|
|
sys.exit(app.exec()) |
|
|
|
sys.exit(app.exec()) |
|
|
|
else: |
|
|
|
else: |
|
|
|