Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
content = s(urlopen(request).read())
# Parse, select and print messages
cur = tuple([int(c) for c in __version__.split('.')])
display = []
lines = content.split('\n')
for line in lines:
if not line.strip().strip('\n'): # pragma: no cover
continue
vrs, cnd, msg = line.split('|')
ref = tuple([int(c) for c in vrs.split('.') if vrs])
if selected(cur, cnd, ref): # pragma: no cover
display.append(msg)
if display: # pragma: no cover
print("%s%s%s" % (colors.RED, " Important messages:", colors.BOLD))
for msg in display:
print(" => %s" % msg)
print((colors.RESET))
return 0
except: # pragma: no cover
return 1
def main():
"""Makes an audit report."""
print((colors.BOLD))
print(" isbntools - app and framework for 'all things ISBN'")
print((colors.RESET))
print((" Copyright (C) 2014-2019 Alexandre Lima Conde, Version %s" %
__version__))
print("")
print(" License LGPL v3")
print((NOTICE))
# make audit
from isbntools.app import audit
print((colors.BOLD))
audit()
print((colors.RESET))
# conf file
from isbntools.conf import conf_file
RE_VERSION = re.compile(r"__version__\s*=\s*'(.*)'")
_newversion = re.search(RE_VERSION, content).group(1)
has_newversion = False
try:
newversion = tuple(map(int, _newversion.split('.')))
version = tuple(map(int, __version__.split('.')))
if newversion > version:
has_newversion = True
except:
newversion = None
has_newversion = __version__ != _newversion
if has_newversion and newversion:
print((colors.BOLD + colors.RED))
print((" ** A new version (%s) is available! **" % _newversion))
print((colors.BLUE))
print((" At command line enter: [sudo] pip install -U isbntools"))
print(" or")
print((" Download it from %s"
% "https://pypi.python.org/pypi/isbntools"))
print((colors.RESET))
except:
pass
finally:
sys.exit()
cur = tuple([int(c) for c in __version__.split('.')])
display = []
lines = content.split('\n')
for line in lines:
if not line.strip().strip('\n'): # pragma: no cover
continue
vrs, cnd, msg = line.split('|')
ref = tuple([int(c) for c in vrs.split('.') if vrs])
if selected(cur, cnd, ref): # pragma: no cover
display.append(msg)
if display: # pragma: no cover
print("%s%s%s" % (colors.RED, " Important messages:", colors.BOLD))
for msg in display:
print(" => %s" % msg)
print((colors.RESET))
return 0
except: # pragma: no cover
return 1
version = tuple(map(int, __version__.split('.')))
if newversion > version:
has_newversion = True
except:
newversion = None
has_newversion = __version__ != _newversion
if has_newversion and newversion:
print((colors.BOLD + colors.RED))
print((" ** A new version (%s) is available! **" % _newversion))
print((colors.BLUE))
print((" At command line enter: [sudo] pip install -U isbntools"))
print(" or")
print((" Download it from %s"
% "https://pypi.python.org/pypi/isbntools"))
print((colors.RESET))
except:
pass
finally:
sys.exit()
_newversion = re.search(RE_VERSION, content).group(1)
has_newversion = False
try:
newversion = tuple(map(int, _newversion.split('.')))
version = tuple(map(int, __version__.split('.')))
if newversion > version:
has_newversion = True
except:
newversion = None
has_newversion = __version__ != _newversion
if has_newversion and newversion:
print((colors.BOLD + colors.RED))
print((" ** A new version (%s) is available! **" % _newversion))
print((colors.BLUE))
print((" At command line enter: [sudo] pip install -U isbntools"))
print(" or")
print((" Download it from %s"
% "https://pypi.python.org/pypi/isbntools"))
print((colors.RESET))
except:
pass
finally:
sys.exit()
print("")
print(' Your configuration file is at:')
print(" %s%s%s" % (colors.BOLD, conf_file, colors.RESET))
print("")
# lib version
from isbntools.app import libversion
print(" And 'isbntools' is using:")
print(" 'isbnlib' version %s%s%s with 'range db' %s%s%s" %
(colors.BOLD, libversion, colors.RESET, colors.BOLD, RDDATE[0:8],
colors.RESET))
print("")
# check for updates and pypi packages
print(" Checking %sonline%s services ... %sWAIT%s" %
(colors.BOLD, colors.RESET, colors.BOLD, colors.RESET))
try:
from isbntools.contrib.modules.report import check_pypi
check_pypi()
except:
pass
"""Check available packages in pypi."""
import os
import sys
from subprocess import PIPE, Popen
from isbntools.contrib.modules.uxcolors import _colors as colors
PY2 = sys.version < '3'
PKGS = ('isbntools', 'isbnlib')
WINDOWS = os.name == 'nt'
EOL = '\r\n' if WINDOWS and not PY2 else '\n'
PY3 = not PY2
VIRTUAL = getattr(sys, 'base_prefix', sys.prefix) != sys.prefix \
or hasattr(sys, 'real_prefix')
BOLD = colors.BOLD
RESET = colors.RESET
def shell(shcmd=None):
"""Run a shell command."""
if not shcmd: # pragma: no cover
return
sp = Popen(
shcmd,
shell=True,
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
close_fds=not WINDOWS)
(fo, fe) = (sp.stdout, sp.stderr)
if PY2: # pragma: no cover
import os
import sys
from subprocess import PIPE, Popen
from isbntools.contrib.modules.uxcolors import _colors as colors
PY2 = sys.version < '3'
PKGS = ('isbntools', 'isbnlib')
WINDOWS = os.name == 'nt'
EOL = '\r\n' if WINDOWS and not PY2 else '\n'
PY3 = not PY2
VIRTUAL = getattr(sys, 'base_prefix', sys.prefix) != sys.prefix \
or hasattr(sys, 'real_prefix')
BOLD = colors.BOLD
RESET = colors.RESET
def shell(shcmd=None):
"""Run a shell command."""
if not shcmd: # pragma: no cover
return
sp = Popen(
shcmd,
shell=True,
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
close_fds=not WINDOWS)
(fo, fe) = (sp.stdout, sp.stderr)
if PY2: # pragma: no cover
out = fo.read().strip(EOL)