Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
better message when an error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed May 16, 2015
1 parent e71e56a commit 55e88ab
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
69 changes: 69 additions & 0 deletions _unittests/ut_install/test_regex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
@brief test log(time=20s)
"""

import sys
import os
import unittest
import re

try:
import src
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
import src

try:
import pyquickhelper
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
if "PYQUICKHELPER" in os.environ and len(os.environ["PYQUICKHELPER"]) > 0:
sys.path.append(os.environ["PYQUICKHELPER"])
import pyquickhelper


from src.pymyinstall.installhelper.module_install import ModuleInstall
from pyquickhelper import fLOG


class TestRegex (unittest.TestCase):

def test_1(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")

pattern = 'onclick=.javascript:dl[(]([,\[\]0-9]+) *, *.([0-9&;@?=:A-Zgtl]+).[)].' + \
' title(.+)?.>(.+?-((cp34)|(py3)|(py2[.]py3)|(py33[.]py34))-none-((win_amd64)|(any)).whl)</a>'
raw = """<li><a id='networkx'></a><strong><a href='http://networkx.lanl.gov/'>NetworkX</a></strong>, a package for complex networks.
<ul>
<li><a href='javascript:;' onclick='javascript:dl([97,46,45,116,111,57,50,114,101,112,120,49,53,104,51,107,121,106,119,110,55,108,47], "7D34&lt;?&gt;AFC83B47?:2;151;29@619@&gt;2C4C820C@1B=E")' title='[1.2&#160;MB] [Dec 24, 2014]'>networkx&#8209;1.9.1&#8209;py2.py3&#8209;none&#8209;any.whl</a></li>
</ul>""".replace("&#8209;", "-")
reg = re.compile(pattern)
r = reg.search(raw)
if r:
fLOG(r.groups())
else:
assert False


if __name__ == "__main__":
unittest.main()
6 changes: 5 additions & 1 deletion src/pymyinstall/installhelper/module_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,15 @@ def get_exewheel_url_link(self, file_save=None, wheel=False):
if file_save is not None:
with open(file_save, "w", encoding="utf8") as f:
f.write(page)
keep = []
for line in page.split("\n"):
if "networkx" in line:
keep.append(line)
raise Exception(
"module " +
self.name +
", unable to find regex with pattern: " +
pattern)
pattern + "\nexample:\n" + "\n".join(keep))

if ind == -1:
ind = len(alls[0]) - 1
Expand Down
2 changes: 1 addition & 1 deletion src/pymyinstall/packaged/packaged_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def complete_installation():
ModuleInstall("scs", "wheel"),
ModuleInstall("cvxpy", "wheel"),
ModuleInstall("blist", "wheel"), # better large list
ModuleInstall("conda", "wheel"), # to install packages with conda
ModuleInstall("conda", "pip"), # to install packages with conda
ModuleInstall("libLAS", "wheel", mname="liblas"),
ModuleInstall("liblinear", "wheel"),
ModuleInstall("marisa_trie", "wheel"),
Expand Down

0 comments on commit 55e88ab

Please sign in to comment.