Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pokecli.py #5049

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@
if sys.version_info >= (2, 7, 9):
ssl._create_default_https_context = ssl._create_unverified_context

try:
import pkg_resources
pgoapi_version = pkg_resources.get_distribution("pgoapi").version
if pgoapi_version < '1.1.8':
print "Run following command to get latest update: `pip install -r requirements.txt --upgrade`"
sys.exit(1)
except pkg_resources.DistributionNotFound:
print 'Seems you forgot to install python modules.'
print 'Run: `pip install -r requirements.txt`'
sys.exit(1)
except ImportError as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this good to bypass missing import?

Copy link
Contributor Author

@sohje sohje Sep 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should bypass if import pkg_resources raises ImportError.
If no pgoapi installed, then pkg_resources.DistributionNotFound should raised.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I understand. Thanks
👍

print e
pass

logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(name)10s] [%(levelname)s] %(message)s')
Expand Down