aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bin/track_status.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/track_status.py')
-rw-r--r--bin/track_status.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/track_status.py b/bin/track_status.py
index 9c32ae9..2a974a5 100644
--- a/bin/track_status.py
+++ b/bin/track_status.py
@@ -3,15 +3,18 @@
# For details, see https://github.com/egor-tensin/vk-scripts.
# Distributed under the MIT License.
-import argparse, sys
+import argparse
+import sys
from vk.api import API
from vk.tracking import StatusTracker
from vk.tracking.db import Format as DatabaseFormat
+
DEFAULT_TIMEOUT = StatusTracker.DEFAULT_TIMEOUT
DEFAULT_DB_FORMAT = DatabaseFormat.CSV
+
def _parse_positive_integer(s):
try:
n = int(s)
@@ -21,12 +24,14 @@ def _parse_positive_integer(s):
raise argparse.ArgumentTypeError('must be a positive integer: ' + s)
return n
+
def _parse_database_format(s):
try:
return DatabaseFormat(s)
except ValueError:
raise argparse.ArgumentTypeError('invalid database format: ' + s)
+
def _parse_args(args=None):
if args is None:
args = sys.argv[1:]
@@ -52,6 +57,7 @@ def _parse_args(args=None):
return parser.parse_args(args)
+
def track_status(
uids, timeout=DEFAULT_TIMEOUT,
log_path=None,
@@ -72,8 +78,10 @@ def track_status(
tracker.loop(uids)
+
def main(args=None):
track_status(**vars(_parse_args(args)))
+
if __name__ == '__main__':
main()