This commit is contained in:
Marc Aymerich 2016-07-15 08:41:38 +00:00
parent 43b6fe1719
commit 6ca38f092b
5 changed files with 13 additions and 7 deletions

View File

@ -272,7 +272,7 @@ class MailmanTraffic(ServiceMonitor):
'Nov': '11', 'Nov': '11',
'Dec': '12', 'Dec': '12',
}} }}
mailman_addr = re.compile(r'.*-(admin|bounces|confirm|join|leave|owner|request|subscribe|unsubscribe)@.*') mailman_addr = re.compile(r'.*-(admin|bounces|confirm|join|leave|owner|request|subscribe|unsubscribe)@.*|mailman@.*')
def prepare(object_id, list_name, ini_date): def prepare(object_id, list_name, ini_date):
global lists global lists
@ -315,6 +315,7 @@ class MailmanTraffic(ServiceMonitor):
ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subscribers = ps.communicate()[0].strip() subscribers = ps.communicate()[0].strip()
size *= int(subscribers) size *= int(subscribers)
sys.stderr.write("%s %s*%s traffic*subscribers\\n" % (object_id, size, subscribers))
print object_id, size print object_id, size
""").format(**context) """).format(**context)
) )

View File

@ -135,7 +135,7 @@ class BackendLogAdmin(ChangeViewActionsMixin, admin.ModelAdmin):
'display_created', 'execution_time', 'display_created', 'execution_time',
) )
list_display_links = ('id', 'backend') list_display_links = ('id', 'backend')
list_filter = ('state', 'server', 'backend') list_filter = ('state', 'server', 'backend', 'operations__action')
search_fields = ('script',) search_fields = ('script',)
date_hierarchy = 'created_at' date_hierarchy = 'created_at'
inlines = (BackendOperationInline,) inlines = (BackendOperationInline,)

View File

@ -37,7 +37,7 @@ ORCHESTRATION_DISABLE_EXECUTION = Setting('ORCHESTRATION_DISABLE_EXECUTION',
ORCHESTRATION_BACKEND_CLEANUP_DAYS = Setting('ORCHESTRATION_BACKEND_CLEANUP_DAYS', ORCHESTRATION_BACKEND_CLEANUP_DAYS = Setting('ORCHESTRATION_BACKEND_CLEANUP_DAYS',
7 20
) )

View File

@ -45,17 +45,19 @@ class Last(Aggregation):
def aggregate_history(self, dataset): def aggregate_history(self, dataset):
prev_object_id = None prev_object_id = None
prev_object_repr = None
for mdata in dataset.order_by('object_id', 'created_at'): for mdata in dataset.order_by('object_id', 'created_at'):
object_id = mdata.object_id object_id = mdata.object_id
if object_id != prev_object_id: if object_id != prev_object_id:
if prev_object_id is not None: if prev_object_id is not None:
yield (mdata.content_object_repr, datas) yield (prev_object_repr, datas)
datas = [mdata] datas = [mdata]
else: else:
datas.append(mdata) datas.append(mdata)
prev_object_id = object_id prev_object_id = object_id
prev_object_repr = mdata.content_object_repr
if prev_object_id is not None: if prev_object_id is not None:
yield (mdata.content_object_repr, datas) yield (prev_object_repr, datas)
class MonthlySum(Last): class MonthlySum(Last):
@ -98,7 +100,7 @@ class MonthlySum(Last):
current += mdata.value current += mdata.value
if object_id != prev_object_id: if object_id != prev_object_id:
if prev_object_id is not None: if prev_object_id is not None:
yield(prev.content_object_repr, datas) yield (prev.content_object_repr, datas)
datas = [] datas = []
prev = mdata prev = mdata
prev.ymonth = ymonth prev.ymonth = ymonth

View File

@ -87,7 +87,10 @@ class WordpressMuController(ServiceController):
content = session.get(url, verify=self.VERIFY).content.decode('utf8') content = session.get(url, verify=self.VERIFY).content.decode('utf8')
wpnonce = re.compile('name="_wpnonce_add-blog"\s+value="([^"]*)"') wpnonce = re.compile('name="_wpnonce_add-blog"\s+value="([^"]*)"')
wpnonce = wpnonce.search(content).groups()[0] try:
wpnonce = wpnonce.search(content).groups()[0]
except AttributeError:
raise RuntimeError("wpnonce not foud in %s" % content)
url += '?action=add-site' url += '?action=add-site'
data = { data = {