Code: Select all
zombie_download
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\plugins\zr\modules\version\__init__.py", line 27, in zombie_downloadd
with urlopen(download_url, GAME_PATH, timeout=timeout) as url:
File "..\addons\source-python\Python3\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "..\addons\source-python\Python3\urllib\request.py", line 524, in open
req = meth(req)
File "..\addons\source-python\Python3\urllib\request.py", line 1248, in do_request_
raise TypeError(msg)
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
The code:
Syntax: Select all
from paths import GAME_PATH
from urllib.request import urlopen
from core import echo_console
from commands.server import ServerCommand
Ver = '1.0.2'
download_url = ('https://github.com/srpg/Zombie-Riot/archive/main.zip')
new_version = ('http://cssbestrpg.online/version.txt')
def version_checker(timeout=3):
with urlopen(new_version, timeout=timeout) as url:
return url.read().decode('utf-8')
def check_version():
if version_checker() > Ver:
echo_console('[Zombie Riot] There is %s version available to download!' % (version_checker()))
echo_console('[Zombie Riot] You can download new version from: https://github.com/srpg/Zombie-Riot')
echo_console('[Zombie Riot] You are currently running %s version' % (Ver))
else:
echo_console('[Zombie Riot] There is no new version available!')
def download(timeout=3):
with urlopen(download_url, GAME_PATH, timeout=timeout) as url:
data = url.read()
with GAME_PATH.open('wb') as f:
f.write(data)
@ServerCommand('zombie_download')
def zombie_downloadd(command):
download()
echo_console('[Zombie Riot] You have downloaded newest version to cstrike folder')