def update_dir(self, request=None, directory=None): """Updates translation project's files from version control, retaining uncommitted translations. """ old_stats = self.getquickstats() remote_stats = {} from pootle_misc import versioncontrol try: versioncontrol.update_dir(self.real_path) except IOError, e: logging.error(u"Error during update of %(path)s:\n%(error)s", {"path": self.real_path, "error": e}) if request: msg = _("Failed to update from version control: %(error)s", {"error": e}) messages.error(request, msg) return
def update_dir(self, request=None, directory=None): """Updates translation project's files from version control, retaining uncommitted translations. """ old_stats = self.getquickstats() remote_stats = {} from pootle_misc import versioncontrol try: versioncontrol.update_dir(self.real_path) except IOError, e: logging.error(u"Error during update of %(path)s:\n%(error)s", { "path": self.real_path, "error": e, }) if request: msg = _("Failed to update from version control: %(error)s", {"error": e}) messages.error(request, msg) return
def update_dir(self, request=None, directory=None): """Updates translation project's files from version control, retaining uncommitted translations. """ remote_stats = {} from pootle_misc import versioncontrol try: versioncontrol.update_dir(self.real_path) except IOError as e: logging.exception(u"Error during update of %s", self.real_path) if request: msg = _("Failed to update from version control: %(error)s", {"error": e}) messages.error(request, msg) return all_files, new_files = self.scan_files() new_file_set = set(new_files) from pootle.scripts import hooks # Go through all stores except any pootle-terminology.* ones if directory.is_translationproject(): stores = self.stores.exclude(file="") else: stores = directory.stores.exclude(file="") for store in stores.iterator(): if store in new_file_set: continue store.sync(update_translation=True) filetoupdate = store.file.name try: filetoupdate = hooks.hook(self.project.code, "preupdate", store.file.name) except: pass # keep a copy of working files in memory before updating working_copy = store.file.store versioncontrol.copy_to_podir(filetoupdate) store.file._delete_store_cache() store.file._update_store_cache() try: hooks.hook(self.project.code, "postupdate", store.file.name) except: pass try: logging.debug(u"Parsing version control copy of %s into db", store.file.name) store.update(update_structure=True, update_translation=True) #FIXME: Try to avoid merging if file was not updated logging.debug(u"Merging %s with version control update", store.file.name) store.mergefile(working_copy, None, allownewstrings=False, suggestions=True, notranslate=False, obsoletemissing=False) except Exception: logging.exception(u"Near fatal catastrophe, while merging %s " "with version control copy", store.file.name) working_copy.save() store.update(update_structure=True, update_translation=True) raise if request: msg = \ _(u'Updated project <em>%(project)s</em> from version control', {'project': self.fullname}) messages.info(request, msg) from pootle_app.models.signals import post_vc_update post_vc_update.send(sender=self)
def update_project(self, request): """Updates project translation files from version control, retaining uncommitted translations""" if not check_permission("commit", request): raise PermissionDenied(_("You do not have rights to update from "\ "version control here")) old_stats = self.getquickstats() remote_stats = {} from pootle_misc import versioncontrol versioncontrol.update_dir(self.real_path) all_files, new_files = self.scan_files() new_file_set = set(new_files) from pootle.scripts import hooks # Go through all stores except any pootle-terminology.* ones for store in self.stores.exclude(file="").iterator(): if store in new_file_set: # these won't have to be merged, since they are new remotestats = store.getquickstats() remote_stats = dictsum(remote_stats, remotestats) continue store.sync(update_translation=True) try: hooks.hook(self.project.code, "preupdate", store.file.name) except: pass # keep a copy of working files in memory before updating working_copy = store.file.store store.file._delete_store_cache() store.file._update_store_cache() try: logging.debug(u"Parsing version control copy of %s into db", store.file.name) store.update(update_structure=True, update_translation=True, \ conservative=False) remotestats = store.getquickstats() #FIXME: Try to avoid merging if file was not updated logging.debug(u"Merging %s with version control update", store.file.name) store.mergefile(working_copy, None, allownewstrings=False, suggestions=True, notranslate=False, obsoletemissing=False) except Exception, e: logging.error(u"Near fatal catastrophe, exception %s while " "merging %s with version control copy", e, store.file.name) working_copy.save() store.update(update_structure=True, update_translation=True, \ conservative=False) raise try: hooks.hook(self.project.code, "postupdate", store.file.name) except: pass remote_stats = dictsum(remote_stats, remotestats)
def update_project(self, request): """Updates project translation files from version control, retaining uncommitted translations""" if not check_permission("commit", request): raise PermissionDenied(_("You do not have rights to update from "\ "version control here")) old_stats = self.getquickstats() remote_stats = {} from pootle_misc import versioncontrol versioncontrol.update_dir(self.real_path) all_files, new_files = self.scan_files() new_file_set = set(new_files) from pootle.scripts import hooks # Go through all stores except any pootle-terminology.* ones for store in self.stores.exclude(file="").iterator(): if store in new_file_set: # these won't have to be merged, since they are new remotestats = store.getquickstats() remote_stats = dictsum(remote_stats, remotestats) continue store.sync(update_translation=True) try: hooks.hook(self.project.code, "preupdate", store.file.name) except: pass # keep a copy of working files in memory before updating working_copy = store.file.store store.file._delete_store_cache() store.file._update_store_cache() try: logging.debug(u"Parsing version control copy of %s into db", store.file.name) store.update(update_structure=True, update_translation=True, \ conservative=False) remotestats = store.getquickstats() #FIXME: Try to avoid merging if file was not updated logging.debug(u"Merging %s with version control update", store.file.name) store.mergefile(working_copy, None, allownewstrings=False, suggestions=True, notranslate=False, obsoletemissing=False) except Exception, e: logging.error( u"Near fatal catastrophe, exception %s while " "merging %s with version control copy", e, store.file.name) working_copy.save() store.update(update_structure=True, update_translation=True, \ conservative=False) raise try: hooks.hook(self.project.code, "postupdate", store.file.name) except: pass remote_stats = dictsum(remote_stats, remotestats)
def update_dir(self, request=None, directory=None): """Updates translation project's files from version control, retaining uncommitted translations. """ old_stats = self.getquickstats() remote_stats = {} from pootle_misc import versioncontrol try: versioncontrol.update_dir(self.real_path) except IOError as e: logging.error(u"Error during update of %(path)s:\n%(error)s", { "path": self.real_path, "error": e, }) if request: msg = _("Failed to update from version control: %(error)s", {"error": e}) messages.error(request, msg) return all_files, new_files = self.scan_files() new_file_set = set(new_files) from pootle.scripts import hooks # Go through all stores except any pootle-terminology.* ones if directory.is_translationproject(): stores = self.stores.exclude(file="") else: stores = directory.stores.exclude(file="") for store in stores.iterator(): if store in new_file_set: # these won't have to be merged, since they are new remotestats = store.getquickstats() remote_stats = dictsum(remote_stats, remotestats) continue store.sync(update_translation=True) filetoupdate = store.file.name try: filetoupdate = hooks.hook(self.project.code, "preupdate", store.file.name) except: pass # keep a copy of working files in memory before updating working_copy = store.file.store versioncontrol.copy_to_podir(filetoupdate) store.file._delete_store_cache() store.file._update_store_cache() try: hooks.hook(self.project.code, "postupdate", store.file.name) except: pass try: logging.debug(u"Parsing version control copy of %s into db", store.file.name) store.update(update_structure=True, update_translation=True) remotestats = store.getquickstats() #FIXME: Try to avoid merging if file was not updated logging.debug(u"Merging %s with version control update", store.file.name) store.mergefile(working_copy, None, allownewstrings=False, suggestions=True, notranslate=False, obsoletemissing=False) except Exception as e: logging.error( u"Near fatal catastrophe, exception %s while " "merging %s with version control copy", e, store.file.name) working_copy.save() store.update(update_structure=True, update_translation=True) raise remote_stats = dictsum(remote_stats, remotestats) new_stats = self.getquickstats() if request: msg = [ _(u'Updated project <em>%(project)s</em> from version control', {'project': self.fullname}), stats_message(_(u"Working copy"), old_stats), stats_message(_(u"Remote copy"), remote_stats), stats_message(_(u"Merged copy"), new_stats) ] msg = u"<br/>".join([force_unicode(m) for m in msg]) messages.info(request, msg) from pootle_app.models.signals import post_vc_update post_vc_update.send(sender=self, oldstats=old_stats, remotestats=remote_stats, newstats=new_stats)
def update_dir(self, request=None, directory=None): """Updates translation project's files from version control, retaining uncommitted translations. """ remote_stats = {} from pootle_misc import versioncontrol try: versioncontrol.update_dir(self.real_path) except IOError as e: logging.exception(u"Error during update of %s", self.real_path) if request: msg = _("Failed to update from version control: %(error)s", {"error": e}) messages.error(request, msg) return all_files, new_files = self.scan_files() new_file_set = set(new_files) from pootle.scripts import hooks # Go through all stores except any pootle-terminology.* ones if directory.is_translationproject(): stores = self.stores.exclude(file="") else: stores = directory.stores.exclude(file="") for store in stores.iterator(): if store in new_file_set: continue store.sync(update_translation=True) filetoupdate = store.file.name try: filetoupdate = hooks.hook(self.project.code, "preupdate", store.file.name) except: pass # keep a copy of working files in memory before updating working_copy = store.file.store versioncontrol.copy_to_podir(filetoupdate) store.file._delete_store_cache() store.file._update_store_cache() try: hooks.hook(self.project.code, "postupdate", store.file.name) except: pass try: logging.debug(u"Parsing version control copy of %s into db", store.file.name) store.update(update_structure=True, update_translation=True) #FIXME: Try to avoid merging if file was not updated logging.debug(u"Merging %s with version control update", store.file.name) store.mergefile(working_copy, None, allownewstrings=False, suggestions=True, notranslate=False, obsoletemissing=False) except Exception: logging.exception( u"Near fatal catastrophe, while merging %s " "with version control copy", store.file.name) working_copy.save() store.update(update_structure=True, update_translation=True) raise if request: msg = \ _(u'Updated project <em>%(project)s</em> from version control', {'project': self.fullname}) messages.info(request, msg) from pootle_app.signals import post_vc_update post_vc_update.send(sender=self)