Last active
September 25, 2016 11:18
-
-
Save mrummuka/6e723b528e3e6a7a99e5dec7d184df95 to your computer and use it in GitHub Desktop.
logtb for executing pycaching library's log TB method from command-line. Usage: logtb.py <tracking_code> <msg_to_log>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, datetime, pycaching, time | |
if len(sys.argv) > 2: | |
tbcode = sys.argv[1] | |
tbmsg = sys.argv[2] | |
else: | |
print("arg1=tbcode arg2=logmsg not provided") | |
exit(1) | |
geocaching = pycaching.login() | |
from pycaching.log import Log, Type as LogType | |
log = Log(type=LogType.discovered_it, text=tbmsg, visited=datetime.date.today()) | |
try: | |
trackable = geocaching.get_trackable(tbcode) | |
trackable.post_log(log, tbcode) | |
time.sleep(5) | |
except: | |
print("Unexpected error:", sys.exc_info()[0]) | |
raise | |
print("OK") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment