Skip to content

Commit

Permalink
Add Slappd user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Christensen committed Dec 21, 2019
1 parent 9662f2a commit 6576ad1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
package_data={
'': ['templates/*.j2']
},
version='1.0.5'
version='1.0.6'
)
8 changes: 6 additions & 2 deletions slappd/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
import re
import shutil
import sys

# First Party Imports
from configparser import SafeConfigParser
from operator import itemgetter

# Third Party Imports
import pkg_resources
import requests

# First Party Imports
from jinja2 import Environment, FileSystemLoader

# Global ConfigParser object for configuration options
Expand Down Expand Up @@ -94,10 +95,13 @@ def config_update():

def fetch_untappd_activity():
""" Returns a requests object full of Untappd API data """
version = pkg_resources.get_distribution("slappd").version
headers = {'User-Agent': f'Slappd/{version}'}
if 'timeout' not in CONFIG['untappd']:
CONFIG['untappd']['timeout'] = '10'
try:
request = requests.get(fetch_url('checkin/recent'),
headers=headers,
timeout=int(CONFIG['untappd']['timeout']))
request.encoding = 'utf-8'
return request.json()
Expand Down

0 comments on commit 6576ad1

Please sign in to comment.