class DummyUpdater(wx.Frame): """Dummy updater, to which updaters should inherit.""" def __init__(self, parent): wx.Frame.__init__(self, parent) self.autoupdater = None self.default_text = t("ui.message.update.loading") self.progress = 0 # Event binding pub.subscribe(self.OnGauge, "gauge") pub.subscribe(self.OnText, "text") pub.subscribe(self.OnForceDestroy, "forceDestroy") pub.subscribe(self.OnResponseUpdate, "responseUpdate") def create_updater(self, just_checking=False): """Create a new autoupdater instance.""" self.autoupdate = AutoUpdate(BUILD, self, just_checking=just_checking) self.autoupdate.start() def OnGauge(self, value=0): """The progress indicator changes.""" pass def OnText(self, text=""): """The text of the indicator changes.""" pass def OnForceDestroy(self): """Ask for the window's destruction.""" pass def OnResponseUpdate(self, build=None): """The check for updates is complete.""" pass def UpdateGauge(self, value): """Change the level indicator.""" wx.CallAfter(pub.sendMessage, "gauge", value=value) def UpdateText(self, text): """Change the text.""" wx.CallAfter(pub.sendMessage, "text", text=text) def AskDestroy(self): wx.CallAfter(pub.sendMessage, "forceDestroy") def ResponseUpdate(self, build): """The check for updates has responded. Note: the build parameter may be None (no update is available) or a number (updates are available). """ wx.CallAfter(pub.sendMessage, "responseUpdate", build=build)
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """This file contains the debug updater. It's a console updater that plans on updating CocoMUD client. """ import os from autoupdate import AutoUpdate from version import BUILD autoupdate = AutoUpdate(BUILD, None) print "Checking for updates..." build = autoupdate.check() if build is not None: print "A new update is available: {}.\n".format(build) autoupdate.download(stdout=True) autoupdate.update(stdout=True) else: print "No update is available, but download anyway." autoupdate.download(stdout=True) autoupdate.update(stdout=True) os.system("pause")
def create_updater(self, just_checking=False): """Create a new autoupdater instance.""" self.autoupdate = AutoUpdate(BUILD, self, just_checking=just_checking) self.autoupdate.start()
import argparse import os from autoupdate import AutoUpdate from version import BUILD parser = argparse.ArgumentParser() parser.add_argument( "-z", "--zip", action="store_true", help="Update from a build.zip file instead of downloading the update") args = parser.parse_args() autoupdate = AutoUpdate(BUILD, None) if args.zip: archive = "updating/build.zip" if not os.path.exists(archive): print(f"The archived build {archive!r} couldn't be found.") else: autoupdate.path_archive = archive autoupdate.update(stdout=True) else: print("Checking for updates...") build = autoupdate.check() if build is not None: print("A new update is available: {}.\n".format(build)) autoupdate.download(stdout=True) autoupdate.update(stdout=True) else: