general: always ignore .invalid domains (#10626)
This commit is contained in:
parent
367f2159d1
commit
fb3943a0b9
|
@ -2,9 +2,11 @@ import re
|
|||
import sys
|
||||
import shutil
|
||||
import StringIO
|
||||
import os
|
||||
|
||||
from quixote import cleanup
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.publisher import WcsPublisher
|
||||
|
||||
from utilities import create_temporary_pub
|
||||
|
||||
|
@ -108,3 +110,8 @@ def test_finish_interrupted_request():
|
|||
})
|
||||
response = pub.process_request(req)
|
||||
assert '<p>The requested link' in response.body
|
||||
|
||||
def test_get_tenants():
|
||||
open(os.path.join(WcsPublisher.APP_DIR, 'xxx'), 'w').close()
|
||||
os.mkdir(os.path.join(WcsPublisher.APP_DIR, 'plop.invalid'))
|
||||
assert list(WcsPublisher.get_tenants()) == ['example.net']
|
||||
|
|
|
@ -51,9 +51,7 @@ class CmdCheckHobos(Command):
|
|||
publisher.WcsPublisher.configure(self.config)
|
||||
if sub_options.redeploy:
|
||||
sub_options.ignore_timestamp = True
|
||||
for tenant in os.listdir(publisher.WcsPublisher.APP_DIR):
|
||||
if tenant.endswith('.invalid'):
|
||||
continue
|
||||
for tenant in publisher.WcsPublisher.get_tenants():
|
||||
hobo_json_path = os.path.join(publisher.WcsPublisher.APP_DIR, tenant, 'hobo.json')
|
||||
if not os.path.exists(hobo_json_path):
|
||||
continue
|
||||
|
|
|
@ -45,7 +45,7 @@ class CmdHoboNotify(Command):
|
|||
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):
|
||||
for hostname in publisher.WcsPublisher.get_tenants():
|
||||
app_dir = os.path.join(global_app_dir, hostname)
|
||||
if not os.path.exists(os.path.join(app_dir, 'config.pck')):
|
||||
continue
|
||||
|
|
|
@ -54,7 +54,7 @@ class CmdRebuildIndexes(Command):
|
|||
|
||||
app_dir = pub.app_dir
|
||||
if sub_options.all:
|
||||
hostnames = os.listdir(app_dir)
|
||||
hostnames = publisher.WcsPublisher.get_tenants()
|
||||
else:
|
||||
hostnames = args
|
||||
for hostname in hostnames:
|
||||
|
|
|
@ -93,7 +93,7 @@ class CmdStart(Command):
|
|||
pub = publisher.WcsPublisher.create_publisher(register_cron=False)
|
||||
quixote.cleanup()
|
||||
base_app_dir = pub.app_dir
|
||||
for hostname in os.listdir(base_app_dir):
|
||||
for hostname in publisher.WcsPublisher.get_tenants():
|
||||
tenant_path = os.path.join(base_app_dir, hostname)
|
||||
if not os.path.exists(os.path.join(tenant_path, 'config.pck')):
|
||||
continue
|
||||
|
|
|
@ -76,9 +76,7 @@ def cron(publisher):
|
|||
now = time.localtime()
|
||||
if now[:5] != last[:5]:
|
||||
last = now
|
||||
for hostname in os.listdir(app_dir):
|
||||
if not os.path.isdir(publisher.app_dir):
|
||||
continue
|
||||
for hostname in publisher.get_tenants():
|
||||
pid = os.fork()
|
||||
if pid == 0:
|
||||
publisher.app_dir = os.path.join(app_dir, hostname)
|
||||
|
|
|
@ -997,6 +997,15 @@ class QommonPublisher(Publisher):
|
|||
cls.extra_sources = []
|
||||
cls.extra_sources.append(source)
|
||||
|
||||
@classmethod
|
||||
def get_tenants(cls):
|
||||
for tenant in os.listdir(cls.APP_DIR):
|
||||
if tenant.endswith('.invalid'):
|
||||
continue
|
||||
if not os.path.isdir(os.path.join(cls.APP_DIR, tenant)):
|
||||
continue
|
||||
yield tenant
|
||||
|
||||
|
||||
def get_cfg(key, default = None):
|
||||
r = get_publisher().cfg.get(key, default)
|
||||
|
|
Loading…
Reference in New Issue