Commit 95783f9d authored by heemayl's avatar heemayl

Added version option on hatc

parent 3c01d217
......@@ -14,6 +14,8 @@ from lib.utils import print_msg, read_file, write_file, username_from_euid
from lib.humantime_epoch_converter import main as get_epoch_main
__version__ = '0.1'
DAEMON_IN = '/var/run/hatd/ipc/daemon_in.fifo'
DAEMON_OUT = '/var/run/hatd/ipc/daemon_out.fifo'
DAEMON_PID_FILE = '/var/run/hatd/hatd.pid'
......@@ -306,7 +308,9 @@ def main():
data_seq = ('stop_daemon', True)
data = SendReceiveData(data_seq)
data.check_get_send()
exit(0)
if sys.argv[1] in {'-V', '--version'}:
print_msg(__version__, file=sys.stderr)
exit(0)
if not check_daemon_process(DAEMON_PID_FILE):
print_msg('Daemon (hatd) is not running')
exit(127)
......
......@@ -5,6 +5,7 @@ import fcntl
import logging
import json
import os
import sys
import time
......@@ -34,9 +35,9 @@ class FLock:
self.lockf.close()
def print_msg(msg, flush_stream=True):
def print_msg(msg, flush_stream=True, file=sys.stdout):
'''Wrapper for formatting-printing.'''
print('\n{}\n'.format(msg), end='\n', flush=flush_stream)
print('\n{}\n'.format(msg), end='\n', flush=flush_stream, file=file)
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment