Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 28a02a1

Browse files
committed
updated version checker with pip
1 parent bb7c7e3 commit 28a02a1

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

plotly/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@
3939
print("Your version of Plotly is currently outdated,\n" +
4040
"You're currently running {old}".format(old=__version__) +
4141
", while the latest version is {}".format(_latest))
42+
else:
43+
print("Plotly is currently up to date.\n" +
44+
"Plotly version: {}".format(__version__))

plotly/check_version.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import urllib2 # the lib that handles the url stuff
1+
import os
22
import re
33

4-
54
def get_latest():
6-
data = urllib2.urlopen('https://raw.githubusercontent.com/plotly/plotly.py/master/plotly/version.py') # it's a file like object and works just like a file
7-
version_string = [i for i in data][0]
8-
latest_version = re.findall(r'\'.*\'', version_string)[0][1:-1]
5+
os.system('pip show plotly > pip_version.txt')
6+
with open('pip_version.txt', 'r') as file:
7+
output = [i for i in file][2]
8+
latest_version = re.findall(r'\s.*\n', output)[0][1:-1]
99
return latest_version
1010

1111
def run_duration(f, **kwargs):

plotly/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '1.9.7'
1+
__version__ = '1.9.6'
22

33

0 commit comments

Comments
 (0)