Skip to content

Commit

Permalink
Merge branch 'release/0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
IMMEDIATO Marco committed Jul 6, 2017
2 parents 4ffd04e + 8eb5e67 commit a443fae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES
@@ -1,3 +1,8 @@
Release 0.4
-----------

* sending cookie_secure options to phantom script and added phantomjs command options

Release 0.3.1
-------------

Expand Down
2 changes: 1 addition & 1 deletion src/page_exporter/__init__.py
Expand Up @@ -3,7 +3,7 @@
import os

NAME = 'django_page_exporter'.replace('_', '-')
VERSION = __version__ = (0, 3, 1, 'final', 0)
VERSION = __version__ = (0, 4, 0, 'final', 0)
__author__ = 'Marco Immediato'


Expand Down
5 changes: 4 additions & 1 deletion src/page_exporter/scripts/capture.js
Expand Up @@ -87,7 +87,8 @@ if (config.cookie_name != null) {
phantom.addCookie({
'name': config.cookie_name || 'sessionid',
'value': config.cookie_value || '',
'domain': config.cookie_domain || 'localhost'
'domain': config.cookie_domain || 'localhost',
'secure': config.cookie_secure || false
});
}

Expand Down Expand Up @@ -133,5 +134,7 @@ page.open(address, function (status) {
}


}else if(status == 'fail'){
phantom.exit();
}
});
8 changes: 7 additions & 1 deletion src/page_exporter/utils.py
@@ -1,5 +1,6 @@
from threading import Timer

from django.conf import settings
from django.utils import six
import os
import logging
Expand Down Expand Up @@ -42,6 +43,7 @@ def phantomjs_command_kwargs():
def phantomjs_command():
cmd = conf.PHANTOMJS_CMD
cmd = [cmd]
cmd_optz = conf.CLI_ARGS

# Concatenate with capture script
app_path = os.path.dirname(__file__)
Expand All @@ -51,7 +53,8 @@ def phantomjs_command():
capture = os.path.join(app_path, 'scripts', capture)

assert os.path.exists(capture), 'Cannot find %s' % capture
return cmd + [capture]

return cmd + cmd_optz + [capture]


PHANTOMJS_CMD = phantomjs_command()
Expand Down Expand Up @@ -97,6 +100,9 @@ def page_capture(stream, url, method=None, width=None, height=None,
cmd += ['--cookie_domain=%s' % cookie_domain]
if page_status:
cmd += ['--page_status=%s' % page_status]
if getattr(settings, 'SESSION_COOKIE_SECURE', False):
cmd += ['--cookie_secure=true']

logger.debug(cmd)
# Run PhantomJS process
proc = subprocess.Popen(cmd, **phantomjs_command_kwargs())
Expand Down
3 changes: 3 additions & 0 deletions tests/example_client/settings/default.py
Expand Up @@ -90,4 +90,7 @@

PAGE_EXPORTER_PHANTOMJS_CMD = os.path.join(os.path.dirname(__file__), '..', 'phantomjs', 'phantomjs')

PAGE_EXPORTER_WAIT = '10000'
PAGE_EXPORTER_CLI_ARGS = ['--ignore-ssl-errors=true', '--ssl-protocol=any']

from .logging_conf import * # noqa

0 comments on commit a443fae

Please sign in to comment.