From 5a4c1b1a6a1161466afeafb8f1d5f13e6d210749 Mon Sep 17 00:00:00 2001 From: jaska Date: Thu, 31 May 2018 22:42:27 +0100 Subject: [PATCH] fix windows path problem (#24) * :tada: kick start version 0.1.6 * :hammer: use temp file in system temp folder * :handshake: sync with pypi-mobans * :green_heart: fix broken tests * :books: update change log * :green_heart: no longer we can do binary check * :bug: update scm host * :bug: fix windows path problem. fix #23 * :egg: :ferris_wheel: release 0.1.7 --- .moban.yml | 2 ++ CHANGELOG.rst | 9 +++++++++ changelog.yml | 6 ++++++ docs/source/conf.py | 4 ++-- pyecharts-snapshot.yml | 6 +++--- pyecharts_snapshot/main.py | 10 ++++++++-- setup.py | 10 +++++----- tests/test_snapshot.py | 15 +++++++++++++-- 8 files changed, 48 insertions(+), 14 deletions(-) diff --git a/.moban.yml b/.moban.yml index 85b6815..7fee05e 100644 --- a/.moban.yml +++ b/.moban.yml @@ -3,6 +3,8 @@ configuration: - "setupmobans/templates" - ".moban.d" configuration: pyecharts-snapshot.yml + plugin_dir: + - "setupmobans/plugins" targets: - setup.py: setup.py - requirements.txt: requirements.txt.jj2 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index db1dd3c..27eea44 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,15 @@ Change log ================================================================================ +0.1.7 - 31.05.2018 +-------------------------------------------------------------------------------- + +Fixed +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +#. `#23 `_: phantomjs + on windows does not like absolute path but file uri formatted ones + 0.1.6 - 16.05.2018 -------------------------------------------------------------------------------- diff --git a/changelog.yml b/changelog.yml index 8b6aa51..67cf2ca 100644 --- a/changelog.yml +++ b/changelog.yml @@ -1,6 +1,12 @@ name: pyecharts-snapshot organisation: pyecharts releases: +- changes: + - action: Fixed + details: + - '`#23`: phantomjs on windows does not like absolute path but file uri formatted ones' + date: 31.05.2018 + version: 0.1.7 - changes: - action: Updated details: diff --git a/docs/source/conf.py b/docs/source/conf.py index 3dc904f..35b034e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,8 +16,8 @@ project = u'pyecharts-snapshot' copyright = u'2017-2018 Onni Software Ltd.' -version = '0.1.6' -release = '0.1.6' +version = '0.1.7' +release = '0.1.7' exclude_patterns = [] pygments_style = 'sphinx' html_theme = 'default' diff --git a/pyecharts-snapshot.yml b/pyecharts-snapshot.yml index e3e095a..9177354 100644 --- a/pyecharts-snapshot.yml +++ b/pyecharts-snapshot.yml @@ -3,9 +3,9 @@ organisation: "pyecharts" author: "C.W." contact: "wangc_2011@hotmail.com" company: "Onni Software Ltd." -version: "0.1.6" -current_version: "0.1.6" -release: "0.1.6" +version: "0.1.7" +current_version: "0.1.7" +release: "0.1.7" copyright_year: 2017-2018 command_line_interface: "snapshot" entry_point: "pyecharts_snapshot.main:main" diff --git a/pyecharts_snapshot/main.py b/pyecharts_snapshot/main.py index 428effc..32263ed 100644 --- a/pyecharts_snapshot/main.py +++ b/pyecharts_snapshot/main.py @@ -73,12 +73,11 @@ def make_a_snapshot(file_name, output_name, delay=DEFAULT_DELAY, verbose=True): file_type = output_name.split('.')[-1] pixel_ratio = 2 __actual_delay_in_ms = int(delay * 1000) - # add shell=True and it works on Windows now. proc_params = [ PHANTOMJS_EXEC, os.path.join(get_resource_dir('phantomjs'), 'snapshot.js'), - file_name.replace('\\', '/'), + to_file_uri(file_name), file_type, str(__actual_delay_in_ms), str(pixel_ratio) @@ -163,3 +162,10 @@ def chk_phantomjs(): def get_shell_flag(): return sys.platform == 'win32' + + +def to_file_uri(a_file_name): + __universal_file_name = a_file_name.replace('\\', '/') + if ':' not in a_file_name: + __universal_file_name = os.path.abspath(__universal_file_name) + return 'file:///{0}'.format(__universal_file_name) diff --git a/setup.py b/setup.py index c349d15..945b41c 100644 --- a/setup.py +++ b/setup.py @@ -11,21 +11,21 @@ NAME = 'pyecharts-snapshot' AUTHOR = 'C.W.' -VERSION = '0.1.6' +VERSION = '0.1.7' EMAIL = 'wangc_2011@hotmail.com' LICENSE = 'MIT' ENTRY_POINTS = { 'console_scripts': [ 'snapshot = pyecharts_snapshot.main:main' - ] + ], } DESCRIPTION = ( 'renders pyecharts output as image' ) URL = 'https://github.com/pyecharts/pyecharts-snapshot' +DOWNLOAD_URL = '%s/archive/0.1.7.tar.gz' % URL -DOWNLOAD_URL = '%s/archive/0.1.6.tar.gz' % URL FILES = ['README.rst', 'CONTRIBUTORS.rst', 'CHANGELOG.rst'] KEYWORDS = [ 'echarts', @@ -64,8 +64,8 @@ # You do not need to read beyond this line PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format( sys.executable) -GS_COMMAND = ('gs pyecharts-snapshot v0.1.6 ' + - "Find 0.1.6 in changelog for more details") +GS_COMMAND = ('gs pyecharts-snapshot v0.1.7 ' + + "Find 0.1.7 in changelog for more details") NO_GS_MESSAGE = ('Automatic github release is disabled. ' + 'Please install gease to enable it.') UPLOAD_FAILED_MSG = ( diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index c5e01c7..6a1a36f 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -8,7 +8,7 @@ from platform import python_implementation from pyecharts_snapshot.main import main, make_a_snapshot, PY2 -from pyecharts_snapshot.main import save_as_svg +from pyecharts_snapshot.main import save_as_svg, to_file_uri PY27 = sys.version_info[1] == 7 and PY2 and python_implementation() != "PyPy" HTML_FILE = os.path.join("tests", "fixtures", "render.html") @@ -96,7 +96,8 @@ def test_windows_file_name(self): main() except Exception: print(self.fake_popen.call_args) - eq_(self.fake_popen.call_args[0][0][2], + assert self.fake_popen.call_args[0][0][2].startswith('file:////') + assert self.fake_popen.call_args[0][0][2].endswith( 'tests/fixtures/render.html') def test_default_delay_value(self): @@ -213,6 +214,16 @@ def test_unsupported_file_type(): test_output) +def test_to_file_uri(): + windows_file = 'C:\\user\\tmp.html' + uri = to_file_uri(windows_file) + eq_(uri, 'file:///C:/user/tmp.html') + linux_file = 'tests/fixtures/tmp.html' + uri2 = to_file_uri(linux_file) + assert uri2.startswith('file:////') + assert uri2.endswith(linux_file) + + def get_base64_image(): with open(get_fixture('base64.txt'), 'r') as f: content = f.read().replace('\r\n', '')