mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-26 01:44:11 +00:00
removed deprecated commands: queue, runserver
This commit is contained in:
parent
359129adf9
commit
830255eea3
@ -1,68 +0,0 @@
|
||||
from twisted.internet import reactor, threads
|
||||
|
||||
from scrapy.command import ScrapyCommand
|
||||
from scrapy.commands import runserver
|
||||
from scrapy.exceptions import UsageError
|
||||
from scrapy.utils.conf import arglist_to_dict
|
||||
|
||||
class Command(runserver.Command):
|
||||
|
||||
requires_project = True
|
||||
default_settings = {'LOG_LEVEL': 'WARNING'}
|
||||
|
||||
def syntax(self):
|
||||
return "[options] <list|clear|count|add spider1 ..>"
|
||||
|
||||
def short_desc(self):
|
||||
return "Deprecated command. See Scrapyd documentation."
|
||||
|
||||
def add_options(self, parser):
|
||||
ScrapyCommand.add_options(self, parser)
|
||||
parser.add_option("-a", "--arg", dest="spargs", action="append", default=[], \
|
||||
help="set spider argument (may be repeated)")
|
||||
|
||||
def process_options(self, args, opts):
|
||||
ScrapyCommand.process_options(self, args, opts)
|
||||
try:
|
||||
opts.spargs = arglist_to_dict(opts.spargs)
|
||||
except ValueError:
|
||||
raise UsageError("Invalid -a value, use -a NAME=VALUE", print_help=False)
|
||||
|
||||
def run(self, args, opts):
|
||||
if len(args) < 1:
|
||||
raise UsageError()
|
||||
cmd = args[0]
|
||||
|
||||
import warnings
|
||||
warnings.warn("Scrapy queue command is deprecated - use Scrapyd instead.", \
|
||||
DeprecationWarning)
|
||||
|
||||
q = self.crawler.queue._queue
|
||||
|
||||
if cmd == 'add' and len(args) < 2:
|
||||
raise UsageError()
|
||||
|
||||
d = threads.deferToThread(self._run_in_thread, args, opts, q, cmd)
|
||||
d.addBoth(lambda _: reactor.stop())
|
||||
from scrapy import log
|
||||
log.start()
|
||||
reactor.run()
|
||||
|
||||
def _run_in_thread(self, args, opts, q, cmd):
|
||||
if cmd == 'add':
|
||||
for x in args[1:]:
|
||||
self._call(q.add, x, **opts.spargs)
|
||||
print "Added: name=%s args=%s" % (x, opts.spargs)
|
||||
elif cmd == 'list':
|
||||
x = self._call(q.list)
|
||||
print "\n".join(map(str, x))
|
||||
elif cmd == 'count':
|
||||
print self._call(q.count)
|
||||
elif cmd == 'clear':
|
||||
self._call(q.clear)
|
||||
else:
|
||||
raise UsageError()
|
||||
|
||||
def _call(self, f, *a, **kw):
|
||||
return threads.blockingCallFromThread(reactor, f, *a, **kw)
|
||||
|
@ -1,16 +0,0 @@
|
||||
from scrapy.command import ScrapyCommand
|
||||
from scrapy.conf import settings
|
||||
|
||||
class Command(ScrapyCommand):
|
||||
|
||||
requires_project = True
|
||||
default_settings = {'KEEP_ALIVE': True}
|
||||
|
||||
def short_desc(self):
|
||||
return "Deprecated command. Use 'server' command instead"
|
||||
|
||||
def run(self, args, opts):
|
||||
import warnings
|
||||
warnings.warn("Scrapy queue command is deprecated - use 'server' command instead.", \
|
||||
DeprecationWarning)
|
||||
self.crawler.start()
|
Loading…
x
Reference in New Issue
Block a user