From 143c1680700b1c523af433904f68f1dad3edf76e Mon Sep 17 00:00:00 2001 From: cuu Date: Sun, 27 May 2018 10:50:11 +0800 Subject: [PATCH 1/5] fix update read json --- Menu/GameShell/10_Settings/Update/__init__.py | 14 ++++++++++---- sys.py/config.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Menu/GameShell/10_Settings/Update/__init__.py b/Menu/GameShell/10_Settings/Update/__init__.py index c4aa6a3..8ad8216 100644 --- a/Menu/GameShell/10_Settings/Update/__init__.py +++ b/Menu/GameShell/10_Settings/Update/__init__.py @@ -282,7 +282,7 @@ class UpdatePage(Page): self._Screen.SwapAndShow() elif "gitversion" in json_: ### just use git to run update - if confirm.VERSION != json_["gitversion"]: + if config.VERSION != json_["gitversion"]: self._ConfirmPage._URL = None self._ConfirmPage._MD5 = None self._ConfirmPage._GIT = True @@ -292,10 +292,16 @@ class UpdatePage(Page): self._Screen.Draw() self._ConfirmPage.SnapMsg("Update to %s ?" % json_["gitversion"] ) self._Screen.SwapAndShow() - + else: + self._Screen.Draw() + self._Screen._MsgBox.SetText("Out of update") + self._Screen._MsgBox.Draw() + self._Screen.SwapAndShow() + pygame.time.delay(600) + return True - except: - print("r.json error") + except Exception, e: + print("r.json() error %s" % str(e)) else: print(" requests get error %d ", r.status_code) diff --git a/sys.py/config.py b/sys.py/config.py index b9c8025..227e5d6 100644 --- a/sys.py/config.py +++ b/sys.py/config.py @@ -10,7 +10,7 @@ Battery = "/sys/class/power_supply/axp20x-battery/uevent" MPD_socket = "/tmp/mpd.socket" -UPDATE_URL="http://192.168.31.236:81/version.php" +UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/launcher/master/launcher_ver.json" VERSION="1.0" From c5fcd08ed905aae821ac3b8ea737f5e8f8146937 Mon Sep 17 00:00:00 2001 From: cuu Date: Sun, 27 May 2018 10:57:05 +0800 Subject: [PATCH 2/5] set the update url --- sys.py/config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys.py/config.py b/sys.py/config.py index 227e5d6..363b18e 100644 --- a/sys.py/config.py +++ b/sys.py/config.py @@ -10,7 +10,6 @@ Battery = "/sys/class/power_supply/axp20x-battery/uevent" MPD_socket = "/tmp/mpd.socket" -UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/launcher/master/launcher_ver.json" - +UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/CPI/master/launcher_ver.json" VERSION="1.0" From 27d113c61309f192d49af55bd11aeb3790d2c334 Mon Sep 17 00:00:00 2001 From: cuu Date: Sun, 27 May 2018 11:33:43 +0800 Subject: [PATCH 3/5] In Update,we use hard reset to update versions --- Menu/GameShell/10_Settings/Update/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Menu/GameShell/10_Settings/Update/__init__.py b/Menu/GameShell/10_Settings/Update/__init__.py index 8ad8216..0b4d73e 100644 --- a/Menu/GameShell/10_Settings/Update/__init__.py +++ b/Menu/GameShell/10_Settings/Update/__init__.py @@ -110,7 +110,7 @@ class UpdateConfirmPage(ConfirmPage): if event.key == CurKeys["B"]: if self._GIT == True: - cmdpath = "cd /home/cpi/apps/launcher ;git pull " + cmdpath = "cd /home/cpi/apps/launcher ;git pull; git reset --hard %s " % self._Version pygame.event.post( pygame.event.Event(RUNEVT, message=cmdpath)) self._GIT = False return @@ -286,7 +286,8 @@ class UpdatePage(Page): self._ConfirmPage._URL = None self._ConfirmPage._MD5 = None self._ConfirmPage._GIT = True - + self._ConfirmPage._Version = json_["gitversion"] + self._Screen.PushPage(self._ConfirmPage) self._Screen.Draw() From 6b2ad6a58a66e11aa4a0e4fd4c7d47e53bba640f Mon Sep 17 00:00:00 2001 From: cuu Date: Sun, 27 May 2018 11:45:20 +0800 Subject: [PATCH 4/5] fix git reset hard version control tangle --- Menu/GameShell/10_Settings/Update/__init__.py | 6 ++++-- sys.py/UI/util_funcs.py | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Menu/GameShell/10_Settings/Update/__init__.py b/Menu/GameShell/10_Settings/Update/__init__.py index 0b4d73e..d3f513f 100644 --- a/Menu/GameShell/10_Settings/Update/__init__.py +++ b/Menu/GameShell/10_Settings/Update/__init__.py @@ -14,7 +14,7 @@ from UI.icon_item import IconItem from UI.icon_pool import MyIconPool from UI.label import Label from UI.fonts import fonts -from UI.util_funcs import midRect,CmdClean +from UI.util_funcs import midRect,CmdClean,get_git_revision_short_hash from UI.keys_def import CurKeys from UI.confirm_page import ConfirmPage from UI.download import Download @@ -282,7 +282,9 @@ class UpdatePage(Page): self._Screen.SwapAndShow() elif "gitversion" in json_: ### just use git to run update - if config.VERSION != json_["gitversion"]: + current_git_version = get_git_revision_short_hash() + + if current_git_version != json_["gitversion"]: self._ConfirmPage._URL = None self._ConfirmPage._MD5 = None self._ConfirmPage._GIT = True diff --git a/sys.py/UI/util_funcs.py b/sys.py/UI/util_funcs.py index d08764e..a15d523 100644 --- a/sys.py/UI/util_funcs.py +++ b/sys.py/UI/util_funcs.py @@ -2,6 +2,7 @@ import pygame import os +import subprocess #from libs import easing #from datetime import datetime @@ -11,6 +12,14 @@ import os import string from Xlib import X,display + +def get_git_revision_hash(): + return subprocess.check_output(['git', 'rev-parse', 'HEAD']) + +def get_git_revision_short_hash(): + return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']) + + def X_center_mouse(): d = display.Display() s = d.screen() From 452e583ef6eb57c12797dc011aa7a4bdd14ab3c3 Mon Sep 17 00:00:00 2001 From: cuu Date: Sun, 27 May 2018 11:49:01 +0800 Subject: [PATCH 5/5] bug fix in gitversion,when try to get git revision short hash --- Menu/GameShell/10_Settings/Update/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Menu/GameShell/10_Settings/Update/__init__.py b/Menu/GameShell/10_Settings/Update/__init__.py index d3f513f..de17ef4 100644 --- a/Menu/GameShell/10_Settings/Update/__init__.py +++ b/Menu/GameShell/10_Settings/Update/__init__.py @@ -282,8 +282,10 @@ class UpdatePage(Page): self._Screen.SwapAndShow() elif "gitversion" in json_: ### just use git to run update + cur_dir = os.getcwd() + os.chdir("/home/cpi/apps/launcher") current_git_version = get_git_revision_short_hash() - + os.chdir(cur_dir) if current_git_version != json_["gitversion"]: self._ConfirmPage._URL = None self._ConfirmPage._MD5 = None