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

Добавлен параметр --wait-another-update для возможности
выбора ожидать завершения параллельного обновления или выйти.
master3.3 3.2.0_alpha7
Mike khiretskiy 10 years ago
parent e4043e8411
commit b931639734

@ -13,10 +13,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from itertools import ifilter
import sys import sys
from os import path from os import path
import os 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.tools import AddonError
from calculate.lib.utils.colortext.palette import TextState from calculate.lib.utils.colortext.palette import TextState
@ -99,6 +102,24 @@ class Update:
dv.Set('cl_update_outdate_set', 'on', force=True) dv.Set('cl_update_outdate_set', 'on', force=True)
return 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): def syncRepositories(self, repname, clean_on_error=True):
""" """
Синхронизировать репозитории Синхронизировать репозитории

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

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

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

Loading…
Cancel
Save