Skip to content

Commit 3658e0f

Browse files
authored
Merge pull request #256 from my8100/release_v160
Release v1.6.0 and use scrapydweb_settings_v11.py
2 parents ca6200d + 321a7d5 commit 3658e0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+64
-10
lines changed

HISTORY.md

+7

scrapydweb/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .__version__ import __url__, __version__
1414
from .common import handle_metadata
1515
from .models import Metadata, db
16-
from .vars import PYTHON_VERSION, SQLALCHEMY_BINDS, SQLALCHEMY_DATABASE_URI
16+
from .vars import PYTHON_VERSION, SCRAPY_VERSION, SCRAPYD_VERSION, SQLALCHEMY_BINDS, SQLALCHEMY_DATABASE_URI
1717
# from .utils.scheduler import scheduler
1818

1919

@@ -54,6 +54,8 @@ def internal_server_error(error):
5454
python_version=PYTHON_VERSION,
5555
scrapydweb_version=__version__,
5656
logparser_version=LOGPARSER_VERSION,
57+
scrapy_version=SCRAPY_VERSION,
58+
scrapyd_version=SCRAPYD_VERSION,
5759
scrapyd_servers_amount=len(current_app.config.get('SCRAPYD_SERVERS', []))
5860
)
5961
return render_template('500.html', **kwargs), 500
@@ -308,6 +310,8 @@ def inject_variable():
308310
GITHUB_URL=__url__,
309311
PYTHON_VERSION=PYTHON_VERSION,
310312
SCRAPYDWEB_VERSION=__version__,
313+
SCRAPY_VERSION=SCRAPY_VERSION,
314+
SCRAPYD_VERSION=SCRAPYD_VERSION,
311315

312316
# static_css_common=url_for(STATIC, filename='%s/css/common.css' % VERSION),
313317
static_css_dropdown=url_for(STATIC, filename='%s/css/dropdown.css' % VERSION),

scrapydweb/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding: utf-8
22

33
__title__ = 'scrapydweb'
4-
__version__ = '1.5.2'
4+
__version__ = '1.6.0'
55
__author__ = 'my8100'
66
__author_email__ = '[email protected]'
77
__url__ = 'https://github.com/my8100/scrapydweb'

scrapydweb/default_settings.py

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
('username', 'password', 'localhost', '6801', 'group'),
5252
]
5353

54+
# The default is True, set it to False to skip checking connectivity of scrapyd at startup.
55+
CHECK_SCRAPYD_SERVERS = True
5456

5557
# It's recommended to update the three options below
5658
# if both ScrapydWeb and one of your Scrapyd servers run on the same machine.

scrapydweb/run.py

+9
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ def parse_args(config):
183183
help="current: ENABLE_AUTH = %s, append '--disable_auth' to disable basic auth for web UI" % ENABLE_AUTH
184184
)
185185

186+
CHECK_SCRAPYD_SERVERS = config.get('CHECK_SCRAPYD_SERVERS', True)
187+
parser.add_argument(
188+
'-dc', '--disable_check_scrapyd',
189+
action='store_true',
190+
help="current: CHECK_SCRAPYD_SERVERS = %s, append '--disable_check_scrapyd' skip checking connectivity of scrapyd" % CHECK_SCRAPYD_SERVERS
191+
)
192+
186193
ENABLE_LOGPARSER = config.get('ENABLE_LOGPARSER', False)
187194
parser.add_argument(
188195
'-dlp', '--disable_logparser',
@@ -240,6 +247,8 @@ def update_app_config(config, args):
240247
# action='store_true': default False
241248
if args.disable_auth:
242249
config['ENABLE_AUTH'] = False
250+
if args.disable_check_scrapyd:
251+
config['CHECK_SCRAPYD_SERVERS'] = False
243252
if args.disable_logparser:
244253
config['ENABLE_LOGPARSER'] = False
245254
if args.switch_scheduler_state:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

scrapydweb/templates/500.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ <h1>500 (INTERNAL SERVER ERROR)</h1>
1818
<tr><th>Python</th><td>{{ python_version }}</td></tr>
1919
<tr><th>ScrapydWeb</th><td>{{ scrapydweb_version }}</td></tr>
2020
<tr><th>LogParser</th><td>{{ logparser_version }}</td></tr>
21+
<tr><th>Scrapy</th><td>{{ scrapy_version }}</td></tr>
22+
<tr><th>Scrapyd</th><td>{{ scrapyd_version }}</td></tr>
2123
<tr><th>Scrapyd servers amount</th><td>{{ scrapyd_servers_amount }}</td></tr>
2224
<tr><th>User-Agent</th><td>{{ request.user_agent }}</td></tr>
2325
<tr><th>Request Method</th><td>{{ request.method }}</td></tr>
@@ -44,6 +46,8 @@ <h3><a href="{{ url_issues }}" target="_blank">Step 3: Report the bug with the i
4446
- **Python:** {{ python_version }}
4547
- **ScrapydWeb:** {{ scrapydweb_version }}
4648
- **LogParser:** {{ logparser_version }}
49+
- **Scrapy:** {{ scrapy_version }}
50+
- **Scrapyd:** {{ scrapyd_version }}
4751
- **Scrapyd servers amount:** {{ scrapyd_servers_amount }}
4852
- **User-Agent:** {{ request.user_agent }}
4953
- **Request Method:** {{ request.method }}
@@ -63,4 +67,4 @@ <h3><a href="{{ url_issues }}" target="_blank">Step 3: Report the bug with the i
6367
</script>
6468

6569
</body>
66-
</html>
70+
</html>

scrapydweb/templates/scrapydweb/jobs.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</style>
1616

1717
{% if SCRAPYD_SERVERS_AMOUNT == 1 and (pageview == 1 or pageview % CHECK_LATEST_VERSION_FREQ == 0) %}
18-
<script type="text/javascript" src="https://my8100.pythonanywhere.com/check_update?scrapydweb={{ SCRAPYDWEB_VERSION }}&n={{ SCRAPYD_SERVERS_AMOUNT }}&v={{ PYTHON_VERSION }}&f={{ FEATURES }}&pv={{ pageview }}"></script>
18+
<script type="text/javascript" src="https://my8100.pythonanywhere.com/check_update?scrapydweb={{ SCRAPYDWEB_VERSION }}&n={{ SCRAPYD_SERVERS_AMOUNT }}&v={{ PYTHON_VERSION }}&sc={{ SCRAPY_VERSION }}&sd={{ SCRAPYD_VERSION }}&f={{ FEATURES }}&pv={{ pageview }}"></script>
1919
<script>setTimeout("checkLatestVersion({{ pageview }}, '{{ SCRAPYDWEB_VERSION }}', '{{ GITHUB_URL }}');", 1000);</script>
2020
{% else %}
2121
<script>if(window.localStorage && localStorage.getItem('github') !== null) {localStorage.removeItem('github');}</script>

scrapydweb/templates/scrapydweb/jobs_classic.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</style>
1616

1717
{% if SCRAPYD_SERVERS_AMOUNT == 1 and (pageview == 1 or pageview % CHECK_LATEST_VERSION_FREQ == 0) %}
18-
<script type="text/javascript" src="https://my8100.pythonanywhere.com/check_update?scrapydweb={{ SCRAPYDWEB_VERSION }}&n={{ SCRAPYD_SERVERS_AMOUNT }}&v={{ PYTHON_VERSION }}&f={{ FEATURES }}&pv={{ pageview }}"></script>
18+
<script type="text/javascript" src="https://my8100.pythonanywhere.com/check_update?scrapydweb={{ SCRAPYDWEB_VERSION }}&n={{ SCRAPYD_SERVERS_AMOUNT }}&v={{ PYTHON_VERSION }}&sc={{ SCRAPY_VERSION }}&sd={{ SCRAPYD_VERSION }}&f={{ FEATURES }}&pv={{ pageview }}"></script>
1919
<script>setTimeout("checkLatestVersion({{ pageview }}, '{{ SCRAPYDWEB_VERSION }}', '{{ GITHUB_URL }}');", 1000);</script>
2020
{% else %}
2121
<script>if(window.localStorage && localStorage.getItem('github') !== null) {localStorage.removeItem('github');}</script>

scrapydweb/templates/scrapydweb/jobs_mobileui.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<script type="text/javascript" src="{{ static_js_stacktable }}"></script>
4040

4141
{% if pageview == 1 or pageview % CHECK_LATEST_VERSION_FREQ == 0 %}
42-
<script type="text/javascript" src="https://my8100.pythonanywhere.com/check_update?scrapydweb={{ SCRAPYDWEB_VERSION }}&n={{ SCRAPYD_SERVERS_AMOUNT }}&v={{ PYTHON_VERSION }}&f={{ FEATURES }}&pv={{ pageview }}"></script>
42+
<script type="text/javascript" src="https://my8100.pythonanywhere.com/check_update?scrapydweb={{ SCRAPYDWEB_VERSION }}&n={{ SCRAPYD_SERVERS_AMOUNT }}&v={{ PYTHON_VERSION }}&sc={{ SCRAPY_VERSION }}&sd={{ SCRAPYD_VERSION }}&f={{ FEATURES }}&pv={{ pageview }}"></script>
4343
<script>setTimeout("checkLatestVersion({{ pageview }}, '{{ SCRAPYDWEB_VERSION }}', '{{ GITHUB_URL }}');", 1000);</script>
4444
{% else %}
4545
<script>if(window.localStorage && localStorage.getItem('github') !== null) {localStorage.removeItem('github');}</script>

scrapydweb/templates/scrapydweb/servers.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636
</style>
3737
{% if SCRAPYD_SERVERS_AMOUNT > 1 and (pageview == 1 or pageview % CHECK_LATEST_VERSION_FREQ == 0) %}
38-
<script type="text/javascript" src="https://my8100.pythonanywhere.com/check_update?scrapydweb={{ SCRAPYDWEB_VERSION }}&n={{ SCRAPYD_SERVERS_AMOUNT }}&v={{ PYTHON_VERSION }}&f={{ FEATURES }}&pv={{ pageview }}"></script>
38+
<script type="text/javascript" src="https://my8100.pythonanywhere.com/check_update?scrapydweb={{ SCRAPYDWEB_VERSION }}&n={{ SCRAPYD_SERVERS_AMOUNT }}&v={{ PYTHON_VERSION }}&sc={{ SCRAPY_VERSION }}&sd={{ SCRAPYD_VERSION }}&f={{ FEATURES }}&pv={{ pageview }}"></script>
3939
<script>setTimeout("checkLatestVersion({{ pageview }}, '{{ SCRAPYDWEB_VERSION }}', '{{ GITHUB_URL }}');", 2000);</script>
4040
{% else %}
4141
<script>if(window.localStorage && localStorage.getItem('github') !== null) {localStorage.removeItem('github');}</script>

scrapydweb/templates/scrapydweb/settings.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ <h2><a class="link" target="_blank" href="{{ GITHUB_URL }}/blob/master/scrapydwe
1313

1414
<div class="wrap collapse-wrap">
1515
<ul class="collapse">
16+
<li><div class="title"><h4>Python version: {{ python_version }}</h4></div></li>
1617
<li>
1718
<div class="title"><h4>default_settings.py</h4><i class="iconfont icon-right"></i></div>
1819
<p>{{ DEFAULT_SETTINGS_PY_PATH }}</p>
@@ -34,6 +35,7 @@ <h2><a class="link" target="_blank" href="{{ GITHUB_URL }}/blob/master/scrapydwe
3435
<div class="wrap collapse-wrap">
3536
<h3>ScrapydWeb</h3>
3637
<ul class="collapse">
38+
<li><div class="title"><h4>version: {{ scrapydweb_version }}</h4></div></li>
3739
<li>
3840
<div class="title"><h4>* server *</h4><i class="iconfont icon-right"></i></div>
3941
<pre>{{ scrapydweb_server }}</pre>
@@ -48,6 +50,7 @@ <h3>ScrapydWeb</h3>
4850
<div class="wrap collapse-wrap">
4951
<h3>Scrapy</h3>
5052
<ul class="collapse">
53+
<li><div class="title"><h4>version: {{ scrapy_version }}</h4></div></li>
5154
<li>
5255
<div class="title"><h4>SCRAPY_PROJECTS_DIR</h4><i class="iconfont icon-right"></i></div>
5356
<pre>{{ SCRAPY_PROJECTS_DIR }}</pre>
@@ -58,10 +61,12 @@ <h3>Scrapy</h3>
5861
<div class="wrap collapse-wrap">
5962
<h3>Scrapyd</h3>
6063
<ul class="collapse">
64+
<li><div class="title"><h4>version: {{ scrapyd_version }}</h4></div></li>
6165
<li>
6266
<div class="title"><h4>* servers *</h4><i class="iconfont icon-right"></i></div>
6367
<pre>{{ servers }}</pre>
6468
</li>
69+
<li><div class="title"><h4>CHECK_SCRAPYD_SERVERS = {{ CHECK_SCRAPYD_SERVERS }}</h4></div></li>
6570
<li>
6671
<div class="title"><h4>LOCAL_SCRAPYD_SERVER</h4><i class="iconfont icon-right"></i></div>
6772
<pre>{{ LOCAL_SCRAPYD_SERVER }}</pre>
@@ -80,8 +85,8 @@ <h3>Scrapyd</h3>
8085
<div class="wrap collapse-wrap">
8186
<h3>LogParser</h3>
8287
<ul class="collapse">
83-
<li><div class="title"><h4>ENABLE_LOGPARSER = {{ ENABLE_LOGPARSER }}</h4></div></li>
8488
<li><div class="title"><h4>version: {{ logparser_version }}</h4></div></li>
89+
<li><div class="title"><h4>ENABLE_LOGPARSER = {{ ENABLE_LOGPARSER }}</h4></div></li>
8590
<li>
8691
<div class="title"><h4>settings.py</h4><i class="iconfont icon-right"></i></div>
8792
<p>{{ logparser_settings_py_path }}</p>

scrapydweb/utils/check_app_config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def check_assert(key, default, is_instance, allow_zero=True, non_empty=False, co
104104
logger.info("Setting up SCRAPY_PROJECTS_DIR: %s", handle_slash(SCRAPY_PROJECTS_DIR))
105105

106106
# Scrapyd
107+
check_assert('CHECK_SCRAPYD_SERVERS', True, bool)
107108
check_scrapyd_servers(config)
108109
# For JobsView
109110
for node, scrapyd_server in enumerate(config['SCRAPYD_SERVERS'], 1):
@@ -385,7 +386,8 @@ def key_func(arg):
385386
return [_group, '.'.join(parts), int(_port)]
386387

387388
servers = sorted(set(servers), key=key_func)
388-
check_scrapyd_connectivity(servers)
389+
if config.get('CHECK_SCRAPYD_SERVERS', True):
390+
check_scrapyd_connectivity(servers)
389391

390392
config['SCRAPYD_SERVERS'] = ['%s:%s' % (ip, port) for (group, ip, port, auth, public_url) in servers]
391393
config['SCRAPYD_SERVERS_GROUPS'] = [group for (group, ip, port, auth, public_url) in servers]

scrapydweb/vars.py

+11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515

1616
PYTHON_VERSION = '.'.join([str(n) for n in sys.version_info[:3]])
1717
PY2 = sys.version_info.major < 3
18+
19+
try:
20+
from scrapy import __version__ as SCRAPY_VERSION
21+
except ImportError:
22+
SCRAPY_VERSION = '0.0.0'
23+
24+
try:
25+
from scrapyd import __version__ as SCRAPYD_VERSION
26+
except ImportError:
27+
SCRAPYD_VERSION = '0.0.0'
28+
1829
SCRAPYDWEB_SETTINGS_PY = 'scrapydweb_settings_v11.py'
1930
sys.path.append(os.getcwd())
2031
try:

scrapydweb/views/baseview.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
from ..vars import (ALLOWED_SCRAPYD_LOG_EXTENSIONS, APSCHEDULER_DATABASE_URI,
1616
DATA_PATH, DEMO_PROJECTS_PATH, DEPLOY_PATH, PARSE_PATH,
1717
ALERT_TRIGGER_KEYS, LEGAL_NAME_PATTERN, SCHEDULE_ADDITIONAL,
18-
SCHEDULE_PATH, STATE_PAUSED, STATE_RUNNING, STATS_PATH, STRICT_NAME_PATTERN)
18+
SCHEDULE_PATH, STATE_PAUSED, STATE_RUNNING, STATS_PATH, STRICT_NAME_PATTERN,
19+
PYTHON_VERSION, SCRAPY_VERSION, SCRAPYD_VERSION)
1920
from ..utils.scheduler import scheduler
2021

2122

2223
class BaseView(View):
24+
PYTHON_VERSION = PYTHON_VERSION
2325
SCRAPYDWEB_VERSION = SCRAPYDWEB_VERSION
2426
LOGPARSER_VERSION = LOGPARSER_VERSION
27+
SCRAPY_VERSION = SCRAPY_VERSION
28+
SCRAPYD_VERSION = SCRAPYD_VERSION
2529

2630
DEMO_PROJECTS_PATH = DEMO_PROJECTS_PATH
2731
DEPLOY_PATH = DEPLOY_PATH
@@ -99,6 +103,7 @@ def __init__(self, *args, **kwargs):
99103
self.SCRAPYD_SERVERS_PUBLIC_URLS = (app.config.get('SCRAPYD_SERVERS_PUBLIC_URLS', None)
100104
or [''] * self.SCRAPYD_SERVERS_AMOUNT)
101105

106+
self.CHECK_SCRAPYD_SERVERS = app.config.get('CHECK_SCRAPYD_SERVERS', True)
102107
self.LOCAL_SCRAPYD_SERVER = app.config.get('LOCAL_SCRAPYD_SERVER', '')
103108
self.LOCAL_SCRAPYD_LOGS_DIR = app.config.get('LOCAL_SCRAPYD_LOGS_DIR', '')
104109
self.SCRAPYD_LOG_EXTENSIONS = (app.config.get('SCRAPYD_LOG_EXTENSIONS', [])

scrapydweb/views/system/settings.py

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def update_kwargs(self):
5353
self.kwargs['POLL_PID'] = self.POLL_PID
5454

5555
# ScrapydWeb
56+
self.kwargs['python_version'] = self.PYTHON_VERSION
57+
self.kwargs['scrapydweb_version'] = self.SCRAPYDWEB_VERSION
5658
self.kwargs['scrapydweb_server'] = self.json_dumps(dict(
5759
SCRAPYDWEB_BIND=self.SCRAPYDWEB_BIND,
5860
SCRAPYDWEB_PORT=self.SCRAPYDWEB_PORT,
@@ -68,15 +70,18 @@ def update_kwargs(self):
6870
))
6971

7072
# Scrapy
73+
self.kwargs['scrapy_version'] = self.SCRAPY_VERSION
7174
self.kwargs['SCRAPY_PROJECTS_DIR'] = self.handle_slash(self.SCRAPY_PROJECTS_DIR) or "''"
7275

7376
# Scrapyd
77+
self.kwargs['scrapyd_version'] = self.SCRAPYD_VERSION
7478
servers = defaultdict(list)
7579
for group, server, auth in zip(self.SCRAPYD_SERVERS_GROUPS, self.SCRAPYD_SERVERS, self.SCRAPYD_SERVERS_AUTHS):
7680
_server = '%s:%s@%s' % (self.protect(auth[0]), self.protect(auth[1]), server) if auth else server
7781
servers[group].append(_server)
7882

7983
self.kwargs['servers'] = self.json_dumps(servers)
84+
self.kwargs['CHECK_SCRAPYD_SERVERS'] = self.CHECK_SCRAPYD_SERVERS
8085
self.kwargs['LOCAL_SCRAPYD_SERVER'] = self.LOCAL_SCRAPYD_SERVER or "''"
8186
self.kwargs['LOCAL_SCRAPYD_LOGS_DIR'] = self.handle_slash(self.LOCAL_SCRAPYD_LOGS_DIR) or "''"
8287
self.kwargs['SCRAPYD_LOG_EXTENSIONS'] = self.SCRAPYD_LOG_EXTENSIONS

0 commit comments

Comments
 (0)