1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-11-22 16:08:44 -05:00

Merge pull request #2 from hemna/master

Cleaned up trailing whitespace
This commit is contained in:
Craig Lamparter 2018-11-21 12:58:15 -08:00 committed by GitHub
commit a8385c6f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 17 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.pyc

View File

@ -19,7 +19,8 @@
# License GPLv2 # License GPLv2
# #
from fuzzyclock import fuzzy # python included libs
import argparse
import json import json
import urllib import urllib
import sys import sys
@ -33,12 +34,18 @@ from email.mime.text import MIMEText
import subprocess import subprocess
import datetime import datetime
import calendar import calendar
from imapclient import IMAPClient, SEEN
import email import email
import threading import threading
import signal import signal
import pprint import pprint
# external lib imports
from imapclient import IMAPClient, SEEN
# local imports here
from fuzzyclock import fuzzy
import utils
# localization, please edit: # localization, please edit:
HOST = "noam.aprs2.net" # north america tier2 servers round robin HOST = "noam.aprs2.net" # north america tier2 servers round robin
USER = "KM6XXX-9" # callsign of this aprs client with SSID USER = "KM6XXX-9" # callsign of this aprs client with SSID
@ -54,6 +61,24 @@ shortcuts = {
email_sent_dict = {} # message_number:time combos so we don't resend the same email in five mins {int:int} email_sent_dict = {} # message_number:time combos so we don't resend the same email in five mins {int:int}
ack_dict = {} # message_nubmer:ack combos so we stop sending a message after an ack from radio {int:int} ack_dict = {} # message_nubmer:ack combos so we stop sending a message after an ack from radio {int:int}
message_number = 0 # current aprs radio message number, increments for each message we send over rf {int} message_number = 0 # current aprs radio message number, increments for each message we send over rf {int}
# command line args
parser = argparse.ArgumentParser()
parser.add_argument("--user",
metavar="<user>",
default=utils.env("APRS_USER"),
help="The callsign of this ARPS client with SSID"
" Default=env[APRS_USER]")
args = parser.parse_args()
if not args.user:
print("Missing the aprs user")
parser.print_help()
parser.exit()
else:
USER = args.user
try: try:
tn = telnetlib.Telnet(HOST, 14580) tn = telnetlib.Telnet(HOST, 14580)
except Exception, e: except Exception, e:

16
utils.py Normal file
View File

@ -0,0 +1,16 @@
"""Utilities and helper functions."""
import os
import pprint
import sys
def env(*vars, **kwargs):
"""This returns the first environment variable set.
if none are non-empty, defaults to '' or keyword arg default
"""
for v in vars:
value = os.environ.get(v, None)
if value:
return value
return kwargs.get('default', '')