Skip to content

Commit a449dbf

Browse files
authored
Bump version: 1.2.0 to 1.3.0 (#80)
1 parent 7ca184f commit a449dbf

Some content is hidden

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

48 files changed

+77
-38
lines changed

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ jobs:
6969
- run:
7070
name: Setup DATA_PATH
7171
command: |
72-
printf "\nDATA_PATH = '"$DATA_PATH"'\n" >> scrapydweb_settings_v8.py
72+
printf "\nDATA_PATH = '"$DATA_PATH"'\n" >> scrapydweb_settings_v9.py
7373
- when:
7474
condition: <<parameters.use-sqlite>>
7575
steps:
7676
- run:
7777
name: Set DATABASE_URL to sqlite
7878
command: |
79-
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v8.py
79+
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v9.py
8080
- when:
8181
condition: <<parameters.use-postgresql>>
8282
steps:
@@ -91,7 +91,7 @@ jobs:
9191
name: Set DATABASE_URL to postgresql
9292
command: |
9393
# postgres://circleci@127.0.0.1:5432
94-
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v8.py
94+
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v9.py
9595
- when:
9696
condition: <<parameters.use-mysql>>
9797
steps:
@@ -121,7 +121,7 @@ jobs:
121121
name: Set DATABASE_URL to mysql
122122
command: |
123123
# mysql://user:passw0rd@127.0.0.1:3306
124-
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v8.py
124+
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v9.py
125125
126126
- run:
127127
name: Install dependencies
@@ -168,8 +168,8 @@ jobs:
168168
- run:
169169
name: Generate report
170170
command: |
171-
touch scrapydweb_settings_v8.py
172-
cat scrapydweb_settings_v8.py
171+
touch scrapydweb_settings_v9.py
172+
cat scrapydweb_settings_v9.py
173173
echo $DATA_PATH
174174
echo $DATABASE_URL
175175
. venv/bin/activate

HISTORY.md

Lines changed: 15 additions & 0 deletions

README.md

Lines changed: 5 additions & 1 deletion

README_CN.md

Lines changed: 5 additions & 1 deletion

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ APScheduler>=3.5.3
33
flask>=1.0.2
44
flask-compress>=1.4.0
55
Flask-SQLAlchemy>=2.3.2
6-
logparser==0.8.1
6+
logparser==0.8.2
77
requests>=2.21.0
88
setuptools>=40.6.3
99
six>=1.12.0

scrapydweb/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ def register_view(view, endpoint, url_defaults_list):
215215
register_view(DeployUploadView, 'deploy.upload', [('deploy/upload', None)])
216216
register_view(DeployXhrView, 'deploy.xhr', [('deploy/xhr/<eggname>/<project>/<version>', None)])
217217

218-
from .views.operations.schedule import ScheduleView, ScheduleCheckView, ScheduleRunView, ScheduleXhrView, ScheduleTaskView
218+
from .views.operations.schedule import (ScheduleView, ScheduleCheckView, ScheduleRunView,
219+
ScheduleXhrView, ScheduleTaskView)
219220
register_view(ScheduleView, 'schedule', [
220221
('schedule/<project>/<version>/<spider>', None),
221222
('schedule/<project>/<version>', dict(spider=None)),
@@ -271,7 +272,7 @@ def handle_template_context(app):
271272
STATIC = 'static'
272273
VERSION = 'v' + __version__.replace('.', '')
273274
# MUST be commented out for released version
274-
VERSION = 'v121dev'
275+
# VERSION = 'v131dev'
275276

276277
@app.context_processor
277278
def inject_variable():

scrapydweb/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding: utf-8
22

33
__title__ = 'scrapydweb'
4-
__version__ = '1.2.0'
4+
__version__ = '1.3.0'
55
__author__ = 'my8100'
66
__author_email__ = 'my8100@gmail.com'
77
__url__ = 'https://github.com/my8100/scrapydweb'

scrapydweb/default_settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@
6161
# to the Scrapyd server.
6262
# e.g. '127.0.0.1:6800' or 'localhost:6801', do not forget the port number.
6363
LOCAL_SCRAPYD_SERVER = ''
64+
6465
# Enter the directory when you run Scrapyd, run the command below
6566
# to find out where the Scrapy logs are stored:
6667
# python -c "from os.path import abspath, isdir; from scrapyd.config import Config; path = abspath(Config().get('logs_dir')); print(path); print(isdir(path))"
68+
# Check out https://scrapyd.readthedocs.io/en/stable/config.html#logs-dir for more info.
6769
# e.g. 'C:/Users/username/logs' or '/home/username/logs'
6870
LOCAL_SCRAPYD_LOGS_DIR = ''
71+
6972
# The default is False, set it to True to automatically run LogParser as a subprocess at startup.
7073
# Note that you can run the LogParser service separately via command 'logparser' as you like.
7174
# Run 'logparser -h' to find out the config file of LogParser for more advanced settings.

scrapydweb/run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ def load_custom_settings(config):
133133
"Then add your SCRAPYD_SERVERS in the config file and restart scrapydweb.\n".format(
134134
file=SCRAPYDWEB_SETTINGS_PY))
135135
else:
136-
sys.exit("\nThe config file '{file}' has been copied to current working directory.\n"
136+
sys.exit("\nATTENTION:\nYou may encounter ERROR if there are any timer tasks added in v1.2.0,\n"
137+
"and you have to restart scrapydweb and manually restart the stopped tasks.\n"
138+
"\nThe config file '{file}' has been copied to current working directory.\n"
137139
"Please add your SCRAPYD_SERVERS in the config file and restart scrapydweb.\n".format(
138140
file=SCRAPYDWEB_SETTINGS_PY))
139141

scrapydweb/templates/scrapydweb/cluster_reports.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
{% endblock %}
1313

1414
{% block body %}
15-
<h2>{{ selected_nodes|length }} Reports of /{{ project }}/{{ spider }}/{{ job }}/</h2>
15+
<h2>
16+
{% if selected_nodes %}<a class="link" target="_blank" href="{{ url_report }}">{% endif %}
17+
{{ selected_nodes|length }} Reports of /{{ project }}/{{ spider }}/{{ job }}/
18+
{% if selected_nodes %}</a>{% endif %}
19+
</h2>
1620

1721
<form method="post" enctype="multipart/form-data" hidden></form>
1822

scrapydweb/utils/check_app_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def check_connectivity(server):
334334
(_group, _ip, _port, _auth) = server
335335
try:
336336
url = 'http://%s:%s' % (_ip, _port)
337-
r = session.get(url, auth=_auth, timeout=30)
337+
r = session.get(url, auth=_auth, timeout=10)
338338
assert r.status_code == 200, "%s got status_code %s" % (url, r.status_code)
339339
except Exception as err:
340340
logger.error(err)

scrapydweb/utils/setup_database.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def setup_database(database_url, database_path):
5151
'jobs': '/'.join([database_url, DB_JOBS])
5252
}
5353
else:
54+
# db names for backward compatibility
5455
APSCHEDULER_DATABASE_URI = 'sqlite:///' + '/'.join([database_path, 'apscheduler.db'])
5556
# http://flask-sqlalchemy.pocoo.org/2.3/binds/#binds
5657
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + '/'.join([database_path, 'timer_tasks.db'])
@@ -80,7 +81,8 @@ def setup_mysql(username, password, host, port):
8081
"""
8182
ModuleNotFoundError: No module named 'MySQLdb'
8283
pip install mysqlclient
83-
Python 2: pip install mysqlclient -> MySQLdb/_mysql.c(29) : fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
84+
Python 2: pip install mysqlclient -> MySQLdb/_mysql.c(29) :
85+
fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
8486
https://stackoverflow.com/questions/51294268/pip-install-mysqlclient-returns-fatal-error-c1083-cannot-open-file-mysql-h
8587
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient
8688
pip install "path to the downloaded mysqlclient.whl file"
@@ -148,7 +150,8 @@ def setup_postgresql(username, password, host, port):
148150
# creating-utf-8-database-in-postgresql-on-windows10
149151

150152
# cur.execute("CREATE DATABASE %s ENCODING 'UTF8' LC_COLLATE 'en-US' LC_CTYPE 'en-US'" % dbname)
151-
# psycopg2.DataError: new collation (en-US) is incompatible with the collation of the template database (Chinese (Simplified)_People's Republic of China.936)
153+
# psycopg2.DataError: new collation (en-US) is incompatible with the collation of the template database
154+
# (Chinese (Simplified)_People's Republic of China.936)
152155
# HINT: Use the same collation as in the template database, or use template0 as template.
153156
try:
154157
cur.execute("CREATE DATABASE %s ENCODING 'UTF8' LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8'" % dbname)

scrapydweb/vars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
PYTHON_VERSION = '.'.join([str(n) for n in sys.version_info[:3]])
1717
PY2 = sys.version_info.major < 3
18-
SCRAPYDWEB_SETTINGS_PY = 'scrapydweb_settings_v8.py'
18+
SCRAPYDWEB_SETTINGS_PY = 'scrapydweb_settings_v9.py'
1919
try:
2020
custom_settings_module = importlib.import_module(os.path.splitext(SCRAPYDWEB_SETTINGS_PY)[0])
2121
except ImportError:

scrapydweb/views/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ def handle_result(self):
8989
elif self.opt == 'liststats':
9090
if self.js.get('logparser_version') != self.LOGPARSER_VERSION:
9191
if self.project and self.version_spider_job: # 'List Stats' in the Servers page
92-
tip = "'pip install -U logparser' to update LogParser to v%s" % self.LOGPARSER_VERSION
92+
tip = "'pip install --upgrade logparser' to update LogParser to v%s" % self.LOGPARSER_VERSION
9393
self.js = dict(status=self.OK, tip=tip)
9494
else: # XMLHttpRequest in the Jobs page; POST in jobs.py
95-
self.js['tip'] = ("'pip install -U logparser' on host '%s' and run command 'logparser' "
95+
self.js['tip'] = ("'pip install --upgrade logparser' on host '%s' and run command 'logparser' "
9696
"to update LogParser to v%s") % (self.SCRAPYD_SERVER, self.LOGPARSER_VERSION)
9797
self.js['status'] = self.ERROR
9898
elif self.project and self.version_spider_job: # 'List Stats' in the Servers page

scrapydweb/views/dashboard/jobs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,9 @@ def handle_jobs_without_db(self):
367367
else:
368368
if job['finish']:
369369
self.finished_jobs.append(job)
370-
job['url_multinode_run'] = url_for('servers', node=self.node, opt='schedule', project=job['project'],
371-
version_job=self.DEFAULT_LATEST_VERSION, spider=job['spider'])
370+
job['url_multinode_run'] = url_for('servers', node=self.node, opt='schedule',
371+
project=job['project'], version_job=self.DEFAULT_LATEST_VERSION,
372+
spider=job['spider'])
372373
job['url_schedule'] = url_for('schedule', node=self.node, project=job['project'],
373374
version=self.DEFAULT_LATEST_VERSION, spider=job['spider'])
374375
job['url_start'] = url_for('api', node=self.node, opt='start', project=job['project'],
@@ -384,7 +385,7 @@ def handle_jobs_without_db(self):
384385
job['url_stats'] = url_for('log', node=self.node, opt='stats', project=job['project'], ui=self.UI,
385386
spider=job['spider'], job=job['job'], job_finished=job_finished)
386387
job['url_clusterreports'] = url_for('clusterreports', node=self.node, project=job['project'],
387-
spider=job['spider'], job=job['job'])
388+
spider=job['spider'], job=job['job'])
388389
# <a href='/items/demo/test/2018-10-12_205507.jl'>Items</a>
389390
m = re.search(HREF_PATTERN, job['href_items'])
390391
if m:

scrapydweb/views/files/log.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
job_finished_key_dict = defaultdict(OrderedDict)
3434
# For /log/report/
3535
job_finished_report_dict = defaultdict(OrderedDict)
36-
REPORT_KEYS_SET = set(['from_memory', 'status', 'pages', 'items', 'shutdown_reason', 'finish_reason',
37-
'runtime', 'first_log_time', 'latest_log_time', 'log_categories', 'latest_matches'])
36+
REPORT_KEYS_SET = {'from_memory', 'status', 'pages', 'items', 'shutdown_reason', 'finish_reason', 'runtime',
37+
'first_log_time', 'latest_log_time', 'log_categories', 'latest_matches'}
3838

3939

4040
# http://flask.pocoo.org/docs/1.0/api/#flask.views.View
@@ -110,7 +110,7 @@ def __init__(self):
110110
self.email_content_kwargs = {}
111111
self.flag = ''
112112

113-
self.jobs_to_keep = self.JOBS_FINISHED_JOBS_LIMIT or 1000
113+
self.jobs_to_keep = self.JOBS_FINISHED_JOBS_LIMIT or 200
114114

115115
def dispatch_request(self, **kwargs):
116116
if self.report_logparser:
@@ -205,7 +205,7 @@ def request_stats_by_logparser(self):
205205
"Or wait until LogParser parses the log. ") % self.SCRAPYD_SERVER, self.WARN)
206206
return
207207
elif js.get('logparser_version') != self.LOGPARSER_VERSION:
208-
msg = "'pip install -U logparser' on host '%s' to update LogParser to v%s" % (
208+
msg = "'pip install --upgrade logparser' on host '%s' to update LogParser to v%s" % (
209209
self.SCRAPYD_SERVER, self.LOGPARSER_VERSION)
210210
self.logger.warning(msg)
211211
flash(msg, self.WARN)

scrapydweb/views/operations/execute_task.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
EXTRACT_URL_SERVER_PATTERN = re.compile(r'//(.+?:\d+)')
1717

1818

19-
class TaskExecuter(object):
19+
class TaskExecutor(object):
2020

2121
def __init__(self, task_id, task_name, url_scrapydweb, url_schedule_task, url_delete_task_result,
2222
auth, selected_nodes):
@@ -159,14 +159,14 @@ def execute_task(task_id):
159159
username = metadata.get('username', '')
160160
password = metadata.get('password', '')
161161
url_delete_task_result = metadata.get('url_delete_task_result', '/1/tasks/xhr/delete/1/1/')
162-
task_executer = TaskExecuter(task_id=task_id,
162+
task_executor = TaskExecutor(task_id=task_id,
163163
task_name=task.name,
164164
url_scrapydweb=metadata.get('url_scrapydweb', 'http://127.0.0.1:5000'),
165165
url_schedule_task=metadata.get('url_schedule_task', '/1/schedule/task/'),
166166
url_delete_task_result=url_delete_task_result,
167167
auth=(username, password) if username and password else None,
168168
selected_nodes=json.loads(task.selected_nodes))
169169
try:
170-
task_executer.main()
170+
task_executor.main()
171171
except Exception:
172172
apscheduler_logger.error(traceback.format_exc())

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
exec(f.read(), about)
1414

1515
with io.open("README.md", 'r', encoding='utf-8') as f:
16-
long_description = re.sub(r':\w+:\s', '', f.read()) # Remove emojis
16+
long_description = re.sub(r':\w+:\s', '', f.read()) # Remove emoji
1717

1818

1919
setup(
@@ -37,7 +37,7 @@
3737
"flask >= 1.0.2", # May 2, 2018
3838
"flask-compress >= 1.4.0", # Jan 5, 2017
3939
"Flask-SQLAlchemy >= 2.3.2", # Oct 11, 2017
40-
"logparser == 0.8.1",
40+
"logparser == 0.8.2",
4141
"requests >= 2.21.0", # Dec 10, 2018
4242
"setuptools >= 40.6.3", # Dec 11, 2018
4343
"six >= 1.12.0", # Dec 10, 2018

tests/test_aa_logparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def rename(name, restore=False):
128128
replace_file_content(app.config['DEMO_JSON_PATH'], old, new)
129129
req(app, client, view='log', kws=kws,
130130
ins=["Mismatching logparser_version 0.0.0 in local stats",
131-
"pip install -U logparser", "Using local logfile:", tab])
131+
"pip install --upgrade logparser", "Using local logfile:", tab])
132132
replace_file_content(app.config['DEMO_JSON_PATH'], new, old)
133133

134134
# delete ScrapydWeb_demo.json in logs

tests/test_reports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_cluster_reports(app, client):
2828
spider=cst.SPIDER, job=cst.JOBID)
2929
url_redirect_to_clusterreports = url_for('clusterreports', node=1, project=cst.PROJECT,
3030
spider=cst.SPIDER, job=cst.JOBID)
31-
ins = ['<h2>0 Reports of ////</h2>', '>Select a job</el-button>', url_jobs, 'selected_nodes: [],']
31+
ins = ['0 Reports of ////', '>Select a job</el-button>', url_jobs, 'selected_nodes: [],']
3232
nos = ['>Select nodes</el-button>']
3333
req(app, client, view='clusterreports', kws=dict(node=1), ins=ins)
3434

@@ -37,7 +37,7 @@ def test_cluster_reports(app, client):
3737
'1': 'on',
3838
'2': 'on',
3939
}
40-
ins[0] = '<h2>%s Reports of /%s/%s/%s/</h2>' % (len(data), cst.PROJECT, cst.SPIDER, cst.JOBID)
40+
ins[0] = '%s Reports of /%s/%s/%s/' % (len(data), cst.PROJECT, cst.SPIDER, cst.JOBID)
4141
ins[-1] = 'selected_nodes: [1, 2],'
4242
ins.extend(nos)
4343
ins.append(url_servers)

0 commit comments

Comments
 (0)