dp_changelogs: Neustart verbessert

develop
Ahmed Aly 2017-11-24 11:14:06 +01:00
parent 475c570519
commit 1d4d2cfb25
1 changed files with 25 additions and 8 deletions

View File

@ -3,6 +3,7 @@
from subprocess import check_output
import pytz
import os
import multiprocessing
from odoo import models, fields, api, tools
@ -47,14 +48,19 @@ class ChangeLog(models.Model):
com2 = commit.decode("utf-8")
com2 = com2.split(' ')[0]
new_logs = b''
news = False
vals = {}
if last_commit:
com1 = last_commit.commit
changelogs = check_output(["git", "log", "--pretty=oneline", com1 + "..." + com2])
for changelog in changelogs.splitlines():
new_logs += b' '.join(changelog.split(b' ')[1:]) + b'\n'
if new_logs == b'':
vals = {}
if not new_logs == b'':
news = True
else:
news = True
if news:
vals = {
'commit': com2,
'changelogs': new_logs,
@ -65,12 +71,23 @@ class ChangeLog(models.Model):
@api.model
def _get_reboot_vals(self):
last_commit = self.search([], limit=1)
if last_commit and last_commit.ppid != str(os.getppid()):
vals = {
'commit': last_commit.commit,
'changelogs': 'Reboot',
'ppid': str(os.getppid())
}
workers = 1
vals = {}
if tools.config.get('workers', False):
workers = tools.config.get('workers', False)
if last_commit:
if workers > 1 and last_commit.ppid != str(os.getppid()):
vals = {
'commit': last_commit.commit,
'changelogs': 'Reboot',
'ppid': str(os.getppid())
}
if last_commit.ppid != str(os.getpid()):
vals = {
'commit': last_commit.commit,
'changelogs': 'Reboot',
'ppid': str(os.getpid())
}
return vals
@api.model_cr