Updater 2.0
This commit is contained in:
parent
b98b3670b4
commit
d9f973be15
1 changed files with 134 additions and 113 deletions
|
@ -1,7 +1,23 @@
|
||||||
# THIS FILE IS A PART OF VCStudio
|
####################################
|
||||||
# PYTHON 3
|
# #
|
||||||
|
# COPYRIGHT NOTICE #
|
||||||
|
# #
|
||||||
|
# This file is a part of Victori- #
|
||||||
|
# ous Children Studio Organizer. #
|
||||||
|
# Or simply VCStudio. Copyright #
|
||||||
|
# of J.Y.Amihud. But don't be sad #
|
||||||
|
# because I released the entire #
|
||||||
|
# project under a GNU GPL license. #
|
||||||
|
# You may use Version 3 or later. #
|
||||||
|
# See www.gnu.org/licenses if your #
|
||||||
|
# copy has no License file. Please #
|
||||||
|
# note. Ones I used the GPL v2 for #
|
||||||
|
# it. It's no longer the case. #
|
||||||
|
# #
|
||||||
|
####################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import urllib3
|
||||||
|
|
||||||
# GTK module ( Graphical interface
|
# GTK module ( Graphical interface
|
||||||
import gi
|
import gi
|
||||||
|
@ -21,6 +37,7 @@ from project_manager import update_reader
|
||||||
#UI modules
|
#UI modules
|
||||||
from UI import UI_elements
|
from UI import UI_elements
|
||||||
from UI import UI_color
|
from UI import UI_color
|
||||||
|
from UI import UI_Markdown
|
||||||
|
|
||||||
|
|
||||||
def layer(win):
|
def layer(win):
|
||||||
|
@ -49,34 +66,37 @@ def layer(win):
|
||||||
)
|
)
|
||||||
layer.fill()
|
layer.fill()
|
||||||
|
|
||||||
# So it's going to be like a little window in the center of the VCStudio
|
# This is the Markdown UI object.
|
||||||
# with a simple UI. Probably like 2 things. Folder and a projectname.
|
|
||||||
|
UI_Markdown.draw(layer, win, "update_markdown",
|
||||||
|
20,
|
||||||
|
100,
|
||||||
|
win.current["w"]-40,
|
||||||
|
win.current["h"]-200)
|
||||||
|
|
||||||
UI_color.set(layer, win, "node_background")
|
UI_color.set(layer, win, "node_background")
|
||||||
UI_elements.roundrect(layer, win,
|
UI_elements.roundrect(layer, win,
|
||||||
win.current["w"]/2-250,
|
50,
|
||||||
100,
|
win.current["h"]-80,
|
||||||
500,
|
win.current["w"]-100,
|
||||||
win.current["h"]-200,
|
50,
|
||||||
10)
|
10)
|
||||||
|
|
||||||
# Exit button
|
# Exit button
|
||||||
def do():
|
def do():
|
||||||
win.url = "project_manager"
|
win.url = "project_manager"
|
||||||
win.textactive = ""
|
win.textactive = ""
|
||||||
|
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win,
|
UI_elements.roundrect(layer, win,
|
||||||
win.current["w"]/2+210,
|
55,
|
||||||
win.current["h"]-140,
|
win.current["h"]-75,
|
||||||
40,
|
40,
|
||||||
40,
|
40,
|
||||||
10,
|
10,
|
||||||
button=do,
|
button=do,
|
||||||
icon="cancel",
|
icon="cancel",
|
||||||
tip=talk.text("cancel"))
|
tip=talk.text("cancel"))
|
||||||
|
|
||||||
|
|
||||||
# Setting to get all files. Sometimes you need a way to restore the entire
|
# Setting to get all files. Sometimes you need a way to restore the entire
|
||||||
# program. Or sometimes I make mistakes. And want give myself and others a
|
# program. Or sometimes I make mistakes. And want give myself and others a
|
||||||
# simple way to refresh the system. So here I gonna make a button that will
|
# simple way to refresh the system. So here I gonna make a button that will
|
||||||
|
@ -101,25 +121,22 @@ def layer(win):
|
||||||
|
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win,
|
UI_elements.roundrect(layer, win,
|
||||||
win.current["w"]/2-250,
|
110,
|
||||||
win.current["h"]-140,
|
win.current["h"]-75,
|
||||||
420,
|
250,
|
||||||
40,
|
40,
|
||||||
10,
|
10,
|
||||||
button=do,
|
button=do,
|
||||||
icon=ic,
|
icon=ic,
|
||||||
tip=talk.text("update_all_tooltip"))
|
tip=talk.text("update_all_tooltip"))
|
||||||
|
|
||||||
|
|
||||||
UI_color.set(layer, win, "text_normal")
|
UI_color.set(layer, win, "text_normal")
|
||||||
layer.set_font_size(15)
|
layer.set_font_size(15)
|
||||||
layer.move_to(
|
layer.move_to(
|
||||||
win.current["w"]/2-200,
|
150,
|
||||||
win.current["h"]-115)
|
win.current["h"]-50)
|
||||||
layer.show_text(talk.text("update_all")+" "+str(len(win.update["get_all_files"]))+" "+talk.text("files"))
|
layer.show_text(talk.text("update_all")+" "+str(len(win.update["get_all_files"]))+" "+talk.text("files"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Install Updates button
|
# Install Updates button
|
||||||
try:
|
try:
|
||||||
if win.update["count"] or win.settings["Update_all"]:
|
if win.update["count"] or win.settings["Update_all"]:
|
||||||
|
@ -129,8 +146,8 @@ def layer(win):
|
||||||
|
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win,
|
UI_elements.roundrect(layer, win,
|
||||||
win.current["w"]/2+170,
|
win.current["w"]-100,
|
||||||
win.current["h"]-140,
|
win.current["h"]-75,
|
||||||
40,
|
40,
|
||||||
40,
|
40,
|
||||||
10,
|
10,
|
||||||
|
@ -138,35 +155,43 @@ def layer(win):
|
||||||
icon="ok",
|
icon="ok",
|
||||||
tip=talk.text("update_install"))
|
tip=talk.text("update_install"))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# At the top of the Update window there is a selector bar to
|
||||||
|
# select various versions. They will load the page into the
|
||||||
|
# little browser below.
|
||||||
|
|
||||||
|
# For this wee need to clip it.
|
||||||
|
|
||||||
# Clipping everything
|
# Clipping everything
|
||||||
UI_elements.roundrect(layer, win,
|
UI_elements.roundrect(layer, win,
|
||||||
win.current["w"]/2-250,
|
50,
|
||||||
100,
|
20,
|
||||||
500,
|
win.current["w"]-100,
|
||||||
win.current["h"]-260,
|
80,
|
||||||
10,
|
10,
|
||||||
fill=False)
|
fill=False)
|
||||||
layer.clip()
|
layer.clip()
|
||||||
|
|
||||||
clip = [
|
clip = [
|
||||||
win.current["w"]/2-250,
|
50,
|
||||||
100,
|
20,
|
||||||
500,
|
win.current["w"]-100,
|
||||||
win.current["h"]-260]
|
80]
|
||||||
|
|
||||||
# Setting up the scroll
|
# Setting up the scroll
|
||||||
if "pm_update" not in win.scroll:
|
if "pm_update" not in win.scroll:
|
||||||
win.scroll["pm_update"] = 0
|
win.scroll["pm_update"] = 0
|
||||||
|
|
||||||
current_Y = 0 # The max scroll value
|
current_X = 0 # The max scroll value
|
||||||
|
|
||||||
for version in win.update["versions"]:
|
for version in win.update["versions"]:
|
||||||
is_open = win.update["versions"][version]["open"]
|
is_open = win.update["versions"][version]["open"]
|
||||||
files = win.update["versions"][version]["files"]
|
files = win.update["versions"][version]["files"]
|
||||||
link = win.update["versions"][version]["link"]
|
link = win.update["versions"][version]["link"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if version == win.version:
|
if version == win.version:
|
||||||
UI_color.set(layer, win, "node_imagefile")
|
UI_color.set(layer, win, "node_imagefile")
|
||||||
|
@ -179,26 +204,73 @@ def layer(win):
|
||||||
sufix = talk.text("update_available")
|
sufix = talk.text("update_available")
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win,
|
UI_elements.roundrect(layer, win,
|
||||||
win.current["w"]/2-240,
|
current_X + 50 + win.scroll["pm_update"],
|
||||||
110 + current_Y + win.scroll["pm_update"],
|
20,
|
||||||
450,
|
300,
|
||||||
40,
|
40,
|
||||||
10)
|
10)
|
||||||
|
|
||||||
UI_color.set(layer, win, "text_normal")
|
UI_color.set(layer, win, "text_normal")
|
||||||
layer.set_font_size(20)
|
layer.set_font_size(20)
|
||||||
layer.move_to(win.current["w"]/2-180,
|
layer.move_to(current_X + 60 + win.scroll["pm_update"],
|
||||||
current_Y + win.scroll["pm_update"] + 140)
|
45)
|
||||||
layer.show_text(str(version)+" "+sufix)
|
layer.show_text(str(version)+" "+sufix)
|
||||||
|
|
||||||
def do():
|
def do():
|
||||||
|
|
||||||
oscalls.Open(link)
|
# We gonna attempt at previewing the update information in the window
|
||||||
|
# and only if it's not going to work, we gonna launch the browser with
|
||||||
|
# the link. Or do some weird. Like giving a generated page about the
|
||||||
|
# stuff.
|
||||||
|
|
||||||
|
openlink = "wiki/updates/"+str(version)+".md"
|
||||||
|
|
||||||
|
if not os.path.exists(os.getcwd()+"/"+openlink):
|
||||||
|
|
||||||
|
# In case the folder is not there yet
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir("wiki/updates")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Now we are getting the file
|
||||||
|
|
||||||
|
try:
|
||||||
|
http = urllib3.PoolManager()
|
||||||
|
resp = http.request('GET', "https://notabug.org/jyamihud/VCStudio/raw/master/"+openlink)
|
||||||
|
|
||||||
|
# Sometimes we might get a 404 error page
|
||||||
|
|
||||||
|
if not resp.data.decode("utf-8").startswith("<!DOCTYPE html>"):
|
||||||
|
|
||||||
|
s = open(openlink, "wb")
|
||||||
|
s.write(resp.data)
|
||||||
|
s.close()
|
||||||
|
else:
|
||||||
|
1/0 # Else we want to execute the exception
|
||||||
|
except:
|
||||||
|
|
||||||
|
# We gonna make a simple 404 page
|
||||||
|
# And load it
|
||||||
|
|
||||||
|
openlink = "/tmp/404-error-"+str(version)+".md"
|
||||||
|
s = open(openlink, "w")
|
||||||
|
s.write("# Version "+str(version)+" No page :(\n\n")
|
||||||
|
s.write("You can try")
|
||||||
|
s.write("![](../../settings/themes/OldSchool/icons/lbry.png)")
|
||||||
|
s.write("[the LBRY link]("+link.replace("(","%28").replace(")","%29")+").\n\n")
|
||||||
|
s.write("![](../../settings/themes/OldSchool/icons/question.png) [What is LBRY?](../../wiki/extra/LBRY.md)")
|
||||||
|
s.close()
|
||||||
|
|
||||||
|
|
||||||
|
win.current["mdfs"]["update_markdown"] = openlink # Loading MD file into viever
|
||||||
|
win.current["update_markdown_files"] = files # Files, for list of updates
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win,
|
UI_elements.roundrect(layer, win,
|
||||||
win.current["w"]/2-200,
|
current_X + 50 + win.scroll["pm_update"],
|
||||||
110 + current_Y + win.scroll["pm_update"],
|
20,
|
||||||
410,
|
300,
|
||||||
40,
|
40,
|
||||||
10,
|
10,
|
||||||
button=do,
|
button=do,
|
||||||
|
@ -206,76 +278,25 @@ def layer(win):
|
||||||
fill=False,
|
fill=False,
|
||||||
clip=clip)
|
clip=clip)
|
||||||
layer.stroke()
|
layer.stroke()
|
||||||
|
|
||||||
|
# Loading markdown page at start of the update window
|
||||||
|
if not win.current["mdfs"]["update_markdown"]:
|
||||||
|
do()
|
||||||
|
|
||||||
# Open and Close button. A little side triangle thingy.
|
current_X = current_X + 310
|
||||||
|
|
||||||
if is_open:
|
# And finally the scroller for the top bar.
|
||||||
icon = "open"
|
|
||||||
expandcall = talk.text("Compress")
|
|
||||||
else:
|
|
||||||
icon = "closed"
|
|
||||||
expandcall = talk.text("Expand")
|
|
||||||
|
|
||||||
def do():
|
|
||||||
win.update["versions"][version]["open"] = not is_open
|
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win,
|
|
||||||
win.current["w"]/2-240,
|
|
||||||
110 + current_Y + win.scroll["pm_update"],
|
|
||||||
40,
|
|
||||||
40,
|
|
||||||
10,
|
|
||||||
button=do,
|
|
||||||
icon=icon,
|
|
||||||
tip=expandcall,
|
|
||||||
clip=clip)
|
|
||||||
|
|
||||||
current_Y = current_Y + 50
|
|
||||||
|
|
||||||
if is_open:
|
|
||||||
for filename in files:
|
|
||||||
|
|
||||||
UI_color.set(layer, win, "button_active")
|
|
||||||
layer.move_to(win.current["w"]/2-227, 102 + current_Y + win.scroll["pm_update"])
|
|
||||||
layer.line_to(win.current["w"]/2-227, 152 + current_Y + win.scroll["pm_update"])
|
|
||||||
layer.stroke()
|
|
||||||
|
|
||||||
|
|
||||||
gitlink = "https://notabug.org/jyamihud/VCStudio/commits/master/"
|
|
||||||
def do():
|
|
||||||
oscalls.Open(gitlink+filename)
|
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win,
|
|
||||||
win.current["w"]/2-220,
|
|
||||||
110 + current_Y + win.scroll["pm_update"],
|
|
||||||
430,
|
|
||||||
40,
|
|
||||||
10,
|
|
||||||
button=do,
|
|
||||||
tip=talk.text("update_see_history")+"\n"+gitlink+filename,
|
|
||||||
icon="notabug",
|
|
||||||
clip=clip)
|
|
||||||
layer.stroke()
|
|
||||||
|
|
||||||
UI_color.set(layer, win, "text_normal")
|
|
||||||
layer.set_font_size(15)
|
|
||||||
layer.move_to(win.current["w"]/2-170,
|
|
||||||
current_Y + win.scroll["pm_update"] + 140)
|
|
||||||
layer.show_text(str(filename))
|
|
||||||
|
|
||||||
|
|
||||||
current_Y = current_Y + 50
|
|
||||||
|
|
||||||
UI_elements.scroll_area(layer, win, "pm_update",
|
UI_elements.scroll_area(layer, win, "pm_update",
|
||||||
int(win.current["w"]/2-250),
|
50,
|
||||||
100,
|
20,
|
||||||
500,
|
win.current["w"]-100,
|
||||||
win.current["h"]-260,
|
80,
|
||||||
current_Y,
|
current_X,
|
||||||
bar=True,
|
bar=True,
|
||||||
mmb=True,
|
mmb=True,
|
||||||
|
sideways=True,
|
||||||
url="update_layer"
|
url="update_layer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
return surface
|
return surface
|
||||||
|
|
Loading…
Reference in a new issue