general: don't load effective_tld_names.txt in scripts (#9831)

Take the occasion to also avoid registering cron jobs in those situations.
This commit is contained in:
Frédéric Péters 2016-02-02 10:23:12 +01:00
parent 2ba77ca6e4
commit 0419995735
12 changed files with 26 additions and 13 deletions

View File

@ -34,7 +34,8 @@ class CmdBackup(Command):
import publisher
publisher.WcsPublisher.configure(self.config)
pub = publisher.WcsPublisher.create_publisher()
pub = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
hostname = args[0]
pub.app_dir = os.path.join(pub.app_dir, hostname)

View File

@ -79,7 +79,8 @@ class CmdCheckHobos(Command):
for i, extra in enumerate(sub_options.extra):
self.config.set('extra', 'cmd_line_extra_%d' % i, extra)
publisher.WcsPublisher.configure(self.config)
pub = publisher.WcsPublisher.create_publisher()
pub = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
global_app_dir = pub.app_dir
base_url = args[0]

View File

@ -62,7 +62,8 @@ class CmdConvertToSql(Command):
self.config.remove_option('main', 'error_log')
publisher.WcsPublisher.configure(self.config)
pub = publisher.WcsPublisher.create_publisher()
pub = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
hostname = args[0]
pub.app_dir = os.path.join(pub.app_dir, hostname)

View File

@ -31,7 +31,8 @@ class CmdExportSettings(Command):
import publisher
self.config.remove_option('main', 'error_log')
publisher.WcsPublisher.configure(self.config)
pub = publisher.WcsPublisher.create_publisher()
pub = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
pub.app_dir = os.path.join(pub.app_dir, sub_options.vhost)
pub.reload_cfg()
print pub.export_cfg()

View File

@ -42,7 +42,8 @@ class CmdHoboNotify(Command):
import publisher
publisher.WcsPublisher.configure(self.config)
pub = publisher.WcsPublisher.create_publisher()
pub = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
global_app_dir = pub.app_dir
for hostname in os.listdir(global_app_dir):
app_dir = os.path.join(global_app_dir, hostname)

View File

@ -36,7 +36,8 @@ class CmdProcessBounce(Command):
try:
publisher.WcsPublisher.configure(self.config)
pub = publisher.WcsPublisher.create_publisher()
pub = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
except:
# not much we can do if we don't have a publisher object :/
return

View File

@ -49,7 +49,8 @@ class CmdRebuildIndexes(Command):
import publisher
publisher.WcsPublisher.configure(self.config)
pub = publisher.WcsPublisher.create_publisher()
pub = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
app_dir = pub.app_dir
if sub_options.all:

View File

@ -35,7 +35,8 @@ class CmdRestore(Command):
self.config.remove_option('main', 'error_log')
publisher.WcsPublisher.configure(self.config, sub_options.extra)
pub = publisher.WcsPublisher.create_publisher()
pub = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
hostname = args[0]
pub.app_dir = os.path.join(pub.app_dir, hostname)

View File

@ -35,7 +35,8 @@ class CmdRunScript(Command):
import publisher
self.config.remove_option('main', 'error_log')
publisher.WcsPublisher.configure(self.config)
publisher = publisher.WcsPublisher.create_publisher()
publisher = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
publisher.app_dir = os.path.join(publisher.app_dir, sub_options.vhost)
publisher.set_config()
fullpath = os.path.dirname(os.path.abspath(args[0]))

View File

@ -36,7 +36,8 @@ class CmdShell(Command):
import publisher
self.config.remove_option('main', 'error_log')
publisher.WcsPublisher.configure(self.config)
publisher = publisher.WcsPublisher.create_publisher()
publisher = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
publisher.app_dir = os.path.join(publisher.APP_DIR, args[0])
if not os.path.exists(publisher.app_dir):
print 'Application directory %r does not exist.' % publisher.app_dir

View File

@ -68,7 +68,8 @@ class CmdTriggerJumps(Command):
import publisher
self.config.remove_option('main', 'error_log')
publisher.WcsPublisher.configure(self.config)
publisher = publisher.WcsPublisher.create_publisher()
publisher = publisher.WcsPublisher.create_publisher(
register_cron=False, register_tld_names=False)
publisher.app_dir = os.path.join(publisher.app_dir, sub_options.vhost)
publisher.set_config()

View File

@ -744,14 +744,16 @@ class QommonPublisher(Publisher):
cls.etld = etld.etld(filename)
load_effective_tld_names = classmethod(load_effective_tld_names)
def create_publisher(cls, register_cron=True):
def create_publisher(cls, register_cron=True, register_tld_names=True):
cls.load_extra_dirs()
cls.load_translations()
if register_cron:
cls.register_cronjob(CronJob(cls.clean_sessions, minutes=range(0, 60, 5)))
cls.register_cronjob(CronJob(cls.clean_afterjobs, minutes=[random.randint(0, 59)]))
cls.register_cronjob(CronJob(cls.clean_tempfiles, minutes=[random.randint(0, 59)]))
cls.load_effective_tld_names()
if register_tld_names:
cls.load_effective_tld_names()
publisher = cls(cls.root_directory_class(),
session_cookie_name = cls.APP_NAME,