Added logging, fixed tests

This commit is contained in:
Michael Lazar
2017-03-28 22:50:51 -07:00
parent 87576a6dec
commit 92a221305c
7 changed files with 42 additions and 23 deletions

View File

@@ -12,6 +12,7 @@ import six
import requests
from . import docs
from . import packages
from .packages import praw
from .config import Config, copy_default_config, copy_default_mailcap
from .oauth import OAuthHelper
@@ -111,6 +112,14 @@ def main():
warnings.warn(text)
config['ascii'] = True
# Check the praw version
if packages.__praw_bundled__:
_logger.info('Using packaged PRAW distribution')
_logger.info('PRAW commit hash %s' % packages.__praw_hash__)
else:
_logger.info('Packaged PRAW not found, falling back to system distribution')
_logger.info('PRAW version %s' % praw.__version__)
# Construct the reddit user agent
user_agent = docs.AGENT.format(version=__version__)

View File

@@ -1,7 +1,7 @@
"""
This stub allows the end-user to fallback to their system installation of praw
if the bundled package missing. This technique was inspired by the requests
library and how it handles dependencies.
This stub allows the the package to fallback to their system installation of
praw if the bundled package is missing. This technique was inspired by the
requests library and how it handles dependencies.
Reference:
https://github.com/kennethreitz/requests/blob/master/requests/packages/__init__.py
@@ -11,6 +11,7 @@ import sys
__praw_hash__ = 'a632ff005fc09e74a8d3d276adc10aa92638962c'
__praw_bundled__ = True
try:
@@ -21,3 +22,4 @@ except ImportError:
msg = 'Invalid PRAW version {0}, exiting'.format(praw.__version__)
raise RuntimeError(msg)
sys.modules['%s.praw' % __name__] = praw
__praw_bundled__ = False