-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
289 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
'xeHentai', | ||
'xeHentai.util', | ||
'xeHentai.i18n', | ||
'xeHentai.updater', | ||
] | ||
requires = ['requests'] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,49 @@ | ||
#!/usr/bin/env python | ||
|
||
from xeHentai import cli | ||
import os | ||
import sys | ||
import json | ||
import zipfile | ||
from threading import Thread | ||
import xeHentai.const as const | ||
|
||
cli.start() | ||
SRC_UPDATE_FILE = const.SRC_UPDATE_FILE | ||
if const.PY3K: | ||
from importlib import reload | ||
|
||
def load_update(): | ||
if os.path.exists(SRC_UPDATE_FILE): | ||
try: | ||
need_remove = False | ||
update_id = "" | ||
with zipfile.ZipFile(SRC_UPDATE_FILE, 'r') as z: | ||
try: | ||
r = json.loads(z.read("info.json")) | ||
except: | ||
need_remove = True | ||
else: | ||
if 'v' not in r and r['v'] != SRC_UPDATE_VERSION: | ||
# ignoring legacy file | ||
need_remove = True | ||
else: | ||
update_id = r["update_id"] | ||
if need_remove: | ||
os.remove(SRC_UPDATE_FILE) | ||
return | ||
v = const.__version__ | ||
sys.path.insert(0, SRC_UPDATE_FILE) | ||
import xeHentai | ||
reload(xeHentai) | ||
xeHentai.const.VERSION_UPDATE = update_id | ||
xeHentai.const.VERSION_UPDATE_LOADER = v | ||
except: | ||
if sys.path[0] == SRC_UPDATE_FILE: | ||
sys.path.pop(0) | ||
os.remove(SRC_UPDATE_FILE) | ||
|
||
|
||
if __name__ == "__main__": | ||
load_update() | ||
|
||
from xeHentai import cli, i18n | ||
cli.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
from xeHentai import cli | ||
import sys | ||
import json | ||
import zipfile | ||
from threading import Thread | ||
from xeHentai.const import * | ||
|
||
cli.start() | ||
def load_update(): | ||
if os.path.exists(SRC_UPDATE_FILE): | ||
try: | ||
need_remove = False | ||
update_id = "" | ||
with zipfile.ZipFile(SRC_UPDATE_FILE, 'r') as z: | ||
try: | ||
r = json.loads(z.read("info.json")) | ||
except: | ||
need_remove = True | ||
else: | ||
if 'v' not in r and r['v'] != SRC_UPDATE_VERSION: | ||
# ignoring legacy file | ||
need_remove = True | ||
else: | ||
update_id = r["update_id"] | ||
if need_remove: | ||
os.remove(SRC_UPDATE_FILE) | ||
return | ||
sys.path.insert(0, SRC_UPDATE_FILE) | ||
import xeHentai | ||
reload(xeHentai) | ||
xeHentai.const.VERSION_UPDATE = update_id | ||
except ImportError: | ||
if sys.path[0] == SRC_UPDATE_FILE: | ||
sys.path.pop(0) | ||
os.remove(SRC_UPDATE_FILE) | ||
except: | ||
pass | ||
return { "v": SRC_UPDATE_VERSION } | ||
|
||
|
||
if __name__ == "__main__": | ||
load_update() | ||
|
||
from xeHentai import cli, i18n | ||
cli.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# coding:utf-8 | ||
# Contributor: | ||
# fffonion <[email protected]> | ||
|
||
class Updater(object): | ||
def get_latest_release(self, dev=False): | ||
raise NotImplementedError("get_latest_release not implemented") | ||
|
||
def get_src_path_in_archive(self, info): | ||
raise NotImplementedError("get_src_path_in_archive not implemented") | ||
|
||
class UpdateInfo(object): | ||
def __init__(self, update_id, download_link, ts, message): | ||
self.update_id = update_id | ||
self.download_link = download_link | ||
self.message = message | ||
self.ts = ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# coding:utf-8 | ||
# Contributor: | ||
# fffonion <[email protected]> | ||
|
||
import requests | ||
import time | ||
|
||
from . import Updater, UpdateInfo | ||
|
||
class GithubUpdater(Updater): | ||
def __init__(self, session): | ||
self.session = session | ||
|
||
def get_latest_release(self, dev=False): | ||
param = dev and "dev" or "master" | ||
r = self.session.get("https://api.github.com/repos/fffonion/xeHentai/commits?sha=%s" % param) | ||
commit = r.json()[0] | ||
sha = commit["sha"] | ||
url = "https://github.com/fffonion/xeHentai/archive/%s.zip" % sha | ||
|
||
return UpdateInfo( | ||
sha, | ||
url, | ||
commit["commit"]["author"]["date"], | ||
commit["commit"]["message"].replace("\r", " ").replace("\n", " "), | ||
) | ||
|
||
def get_src_path_in_archive(self, info): | ||
return "xeHentai-%s/xeHentai" % info.update_id |
Oops, something went wrong.