Browse Source

Добавлена проверка одновременного запуска update.

Добавлен параметр --wait-another-update для возможности
выбора ожидать завершения параллельного обновления или выйти.
tags/3.2.0_alpha7
Mike khiretskiy 7 years ago
parent
commit
b931639734
4 changed files with 36 additions and 0 deletions
  1. +21
    -0
      update/update.py
  2. +2
    -0
      update/utils/cl_update.py
  3. +12
    -0
      update/variables/update.py
  4. +1
    -0
      update/wsdl_update.py

+ 21
- 0
update/update.py View File

@@ -13,10 +13,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from itertools import ifilter

import sys
from os import path
import os
import time
from calculate.core.server.gen_pid import search_worked_process

from calculate.lib.utils.tools import AddonError
from calculate.lib.utils.colortext.palette import TextState
@@ -99,6 +102,24 @@ class Update:
dv.Set('cl_update_outdate_set', 'on', force=True)
return True

def checkRun(self, wait_update):
"""
Проверить повторный запуск
"""
dv = self.clVars
if filter(lambda x: os.getpid() != x,
search_worked_process('update', dv)):
if not wait_update:
raise UpdateError(_("Update is already running. "
"Try to run later."))
else:
self.startTask(_("Waiting for complete another update"))
while any(ifilter(lambda x: os.getpid() != x,
search_worked_process('update', dv))):
time.sleep(0.3)
self.endTask()
return True

def syncRepositories(self, repname, clean_on_error=True):
"""
Синхронизировать репозитории


+ 2
- 0
update/utils/cl_update.py View File

@@ -202,6 +202,8 @@ class ClUpdateAction(Action):

# список задач для дейсвия
tasks = [
{'name': 'check_run',
'method': 'Update.checkRun(cl_update_wait_another_set)'},
{'name': 'reps_synchronization',
'group': __("Repository synchronization"),
'tasks': [


+ 12
- 0
update/variables/update.py View File

@@ -413,3 +413,15 @@ class VariableClUpdateSyncOnlySet(Variable):
self.Get('cl_update_metadata_force') != "force" and
self.Get('cl_update_eixupdate_force') != "force"):
raise VariableError(_("Select at least one sync repository"))

class VariableClUpdateWaitAnotherSet(Variable):
"""
Ждать завершения другого процесса обновления
"""
type = "bool"
value = "on"
opt = ["--wait-another-update"]

def init(self):
self.label = _("Wait for complete another update")
self.help = _("wait until the other updates or abort")

+ 1
- 0
update/wsdl_update.py View File

@@ -70,6 +70,7 @@ class Wsdl(WsdlBase):
'cl_update_pretend_set',
'cl_update_eixupdate_force',
'cl_update_sync_only_set',
'cl_update_wait_another_set',
'cl_templates_locate',
'cl_verbose_set', 'cl_dispatch_conf'),
next_label=_("Update"))]},


Loading…
Cancel
Save