Skip to content

Commit

Permalink
fixed updater
Browse files Browse the repository at this point in the history
  • Loading branch information
RaSan147 committed Jan 22, 2023
1 parent 9f35a26 commit 6049abe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
2 changes: 2 additions & 0 deletions dev_src/html_admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ <h1 style="text-align: center;">Admin Page</h1>
<div>
<p class="update_text" id="update_text">Checking for Update...</p>
<div class="pagination jsonly" onclick="run_update()" id="run_update" style="display: none;">Run Update</div>
<br><br>
</div>


Expand Down Expand Up @@ -54,6 +55,7 @@ <h1 style="text-align: center;">Admin Page</h1>
}

function run_update() {
byId("update_text").innerText = "Updating...";
fetch('/?update_now')
.then(response => response.json())
.then(data => {
Expand Down
41 changes: 20 additions & 21 deletions dev_src/local_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def __init__(self):
self.MAIN_FILE = os.path.realpath(__file__)
self.MAIN_FILE_dir = os.path.dirname(self.MAIN_FILE)

print(tools.text_box("Running File: ",self.MAIN_FILE))

# OS DETECTION
self.OS = self.get_os()
Expand Down Expand Up @@ -266,7 +265,12 @@ def run_update():


#if i not in get_installed():
if check_installed(i):
if not check_installed(i):
return False

ver = subprocess.check_output(['pyrobox', "-v"]).decode()

if ver > __version__:
return True


Expand All @@ -276,7 +280,6 @@ def run_update():




def reload_server():
"""reload the server process from file"""
file = '"' + config.MAIN_FILE + '"'
Expand Down Expand Up @@ -1163,8 +1166,7 @@ def log_request(self, code='-', size='-'):
"""
if isinstance(code, HTTPStatus):
code = code.value
self.log_message('"%s" %s %s',
self.requestline, str(code), str(size))
self.log_message(f'"{self.requestline}"', code, size)

def log_error(self, *args):
"""Log an error.
Expand All @@ -1177,45 +1179,35 @@ def log_error(self, *args):
XXX This should go to the separate error log.
"""
msg = " ".join(map(str, args))
self.log_message(msg, error = True)
self.log_message(args, error = True)

def log_warning(self, *args):
"""Log a warning"""
msg = " ".join(map(str, args))
self.log_message(msg, warning = True)
self.log_message(args, warning = True)

def log_debug(self, *args):
"""Log a debug message"""
msg = " ".join(map(str, args))
self.log_message(msg, debug = True)
self.log_message(args, debug = True)

def log_info(self, *args):
"""Default log"""
msg = " ".join(map(str, args))
self.log_message(msg)
self.log_message(args)




def log_message(self, format, *args, error = False, warning = False, debug = False):
def log_message(self, *args, error = False, warning = False, debug = False):
"""Log an arbitrary message.
This is used by all other logging functions. Override
it if you have specific logging wishes.
The first argument, FORMAT, is a format string for the
message to be logged. If the format string contains
any % escapes requiring parameters, they should be
specified as subsequent arguments (it's just like
printf!).
The client ip and current date/time are prefixed to
every message.
"""

message = format % args
message = ' '.join(map(str, args))

message = ("# %s by [%s] at [%s] %s\n" %
(self.req_hash, self.address_string(),
Expand Down Expand Up @@ -2943,12 +2935,19 @@ def run(port = None, directory = None, bind = None, arg_parse= True):
default=config.port, type=int,
nargs='?',
help='Specify alternate port [default: 8000]')
parser.add_argument('--version', '-v', action='version',
version=__version__)

args = parser.parse_args()

port = args.port
directory = args.directory
bind = args.bind


print(tools.text_box("Running File: ", config.MAIN_FILE, "Version: ", __version__))



if directory == config.ftp_dir and not os.path.isdir(config.ftp_dir):
print(config.ftp_dir, "not found!\nReseting directory to current directory")
Expand Down
14 changes: 11 additions & 3 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def __init__(self):
self.MAIN_FILE = os.path.realpath(__file__)
self.MAIN_FILE_dir = os.path.dirname(self.MAIN_FILE)

print(tools.text_box("Running File: ",self.MAIN_FILE))

# OS DETECTION
self.OS = self.get_os()
Expand Down Expand Up @@ -270,7 +269,12 @@ def run_update():


#if i not in get_installed():
if check_installed(i):
if not check_installed(i):
return False

ver = subprocess.check_output(['pyrobox', "-v"]).decode()

if ver > __version__:
return True


Expand All @@ -280,7 +284,6 @@ def run_update():




def reload_server():
"""reload the server process from file"""
file = '"' + config.MAIN_FILE + '"'
Expand Down Expand Up @@ -4843,6 +4846,7 @@ class multiclick_counter {
<div>
<p class="update_text" id="update_text">Checking for Update...</p>
<div class="pagination jsonly" onclick="run_update()" id="run_update" style="display: none;">Run Update</div>
<br><br>
</div>
Expand Down Expand Up @@ -4886,6 +4890,7 @@ class multiclick_counter {
}
function run_update() {
byId("update_text").innerText = "Updating...";
fetch('/?update_now')
.then(response => response.json())
.then(data => {
Expand Down Expand Up @@ -4947,6 +4952,9 @@ def run(port = None, directory = None, bind = None, arg_parse= True):
bind = args.bind


print(tools.text_box("Running File: ", config.MAIN_FILE))


if directory == config.ftp_dir and not os.path.isdir(config.ftp_dir):
print(config.ftp_dir, "not found!\nReseting directory to current directory")
directory = "."
Expand Down

0 comments on commit 6049abe

Please sign in to comment.