mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Further lint cleaning
This commit is contained in:
parent
060af7ff04
commit
83fd9ca83a
@ -6,7 +6,7 @@ import subprocess
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
from app.classes.steamcmd.steamcmd_command import SteamCMD_command
|
from app.classes.steamcmd.steamcmd_command import SteamCMDcommand
|
||||||
|
|
||||||
|
|
||||||
package_links = {
|
package_links = {
|
||||||
@ -169,7 +169,7 @@ class SteamCMD:
|
|||||||
self._uname = uname if uname else input("Please enter steam username: ")
|
self._uname = uname if uname else input("Please enter steam username: ")
|
||||||
self._passw = passw if passw else getpass("Please enter steam password: ")
|
self._passw = passw if passw else getpass("Please enter steam password: ")
|
||||||
|
|
||||||
steam_command = SteamCMD_command()
|
steam_command = SteamCMDcommand()
|
||||||
return self.execute(steam_command)
|
return self.execute(steam_command)
|
||||||
|
|
||||||
def app_update(
|
def app_update(
|
||||||
@ -189,7 +189,7 @@ class SteamCMD:
|
|||||||
:param betapassword: Optional parameter for entering beta password.
|
:param betapassword: Optional parameter for entering beta password.
|
||||||
:return: Status code of child process.
|
:return: Status code of child process.
|
||||||
"""
|
"""
|
||||||
steam_command = SteamCMD_command()
|
steam_command = SteamCMDcommand()
|
||||||
if install_dir:
|
if install_dir:
|
||||||
steam_command.force_install_dir(install_dir)
|
steam_command.force_install_dir(install_dir)
|
||||||
steam_command.app_update(app_id, validate, beta, betapassword)
|
steam_command.app_update(app_id, validate, beta, betapassword)
|
||||||
@ -218,13 +218,13 @@ class SteamCMD:
|
|||||||
:return: Status code of child process.
|
:return: Status code of child process.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
steam_command = SteamCMD_command()
|
steam_command = SteamCMDcommand()
|
||||||
if install_dir:
|
if install_dir:
|
||||||
steam_command.force_install_dir(install_dir)
|
steam_command.force_install_dir(install_dir)
|
||||||
steam_command.workshop_download_item(app_id, workshop_id, validate)
|
steam_command.workshop_download_item(app_id, workshop_id, validate)
|
||||||
return self.execute(steam_command, n_tries)
|
return self.execute(steam_command, n_tries)
|
||||||
|
|
||||||
def execute(self, cmd: SteamCMD_command, n_tries: int = 1):
|
def execute(self, cmd: SteamCMDcommand, n_tries: int = 1):
|
||||||
"""
|
"""
|
||||||
Executes a SteamCMD_command, with added actions occurring sequentially.
|
Executes a SteamCMD_command, with added actions occurring sequentially.
|
||||||
May retry multiple times on timeout due to valves' timeout on large downloads.
|
May retry multiple times on timeout due to valves' timeout on large downloads.
|
||||||
@ -257,10 +257,11 @@ class SteamCMD:
|
|||||||
f"Download timeout! Tries remaining: {n_tries}. Retrying..."
|
f"Download timeout! Tries remaining: {n_tries}. Retrying..."
|
||||||
)
|
)
|
||||||
return self.execute(cmd, n_tries - 1)
|
return self.execute(cmd, n_tries - 1)
|
||||||
|
|
||||||
# SteamCMD sometimes crashes when timing out downloads, due to
|
# SteamCMD sometimes crashes when timing out downloads, due to
|
||||||
# an assert checking that the download actually finished.
|
# an assert checking that the download actually finished.
|
||||||
# If this happens, retry.
|
# If this happens, retry.
|
||||||
elif e.returncode == 134:
|
if e.returncode == 134:
|
||||||
self._print_log(
|
self._print_log(
|
||||||
f"SteamCMD errored! Tries remaining: {n_tries}. Retrying..."
|
f"SteamCMD errored! Tries remaining: {n_tries}. Retrying..."
|
||||||
)
|
)
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
class SteamCMD_command:
|
class SteamCMDcommand:
|
||||||
"""
|
"""
|
||||||
Used to construct a sequence of commands to sequentially be executed by SteamCMD.
|
Used to construct a sequence of commands to sequentially be executed by SteamCMD.
|
||||||
This reduces the number of required logins, which when using the other provided
|
This reduces the number of required logins, which when using the other provided
|
||||||
methods may result in getting rate limited by Steam.
|
methods may result in getting rate limited by Steam.
|
||||||
To be used with the SteamCMD.execute() method.
|
To be used with the SteamCMD.execute() method.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_commands = []
|
_commands = []
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -12,43 +13,51 @@ class SteamCMD_command:
|
|||||||
|
|
||||||
def force_install_dir(self, install_dir: str):
|
def force_install_dir(self, install_dir: str):
|
||||||
"""
|
"""
|
||||||
Sets the install directory for following app_update and workshop_download_item commands
|
Sets the install directory for following app_update and workshop_download_item
|
||||||
|
commands
|
||||||
|
|
||||||
:param install_dir: Directory to install to
|
:param install_dir: Directory to install to
|
||||||
:return: Index command was added at
|
:return: Index command was added at
|
||||||
"""
|
"""
|
||||||
self._commands.append('+force_install_dir "{}"'.format(install_dir))
|
self._commands.append(f"+force_install_dir {install_dir}")
|
||||||
return len(self._commands) - 1
|
return len(self._commands) - 1
|
||||||
|
|
||||||
def app_update(self, app_id: int, validate: bool = False, beta: str = '', beta_pass: str = ''):
|
def app_update(
|
||||||
|
self, app_id: int, validate: bool = False, beta: str = "", beta_pass: str = ""
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Updates/installs an app
|
Updates/installs an app
|
||||||
:param app_id: The Steam ID for the app you want to install
|
:param app_id: The Steam ID for the app you want to install
|
||||||
:param validate: Optional parameter for validation. Turn this on when updating something
|
:param validate: Optional. Turn this on when updating something
|
||||||
:param beta: Optional parameter for running a beta branch.
|
:param beta: Optional parameter for running a beta branch.
|
||||||
:param beta_pass: Optional parameter for entering beta password.
|
:param beta_pass: Optional parameter for entering beta password.
|
||||||
:return: Index command was added at
|
:return: Index command was added at
|
||||||
"""
|
"""
|
||||||
self._commands.append('+app_update {}{}{}{}'.format(
|
self._commands.append(
|
||||||
app_id,
|
f"+app_update "
|
||||||
' validate' if validate else '',
|
f"{app_id}"
|
||||||
' -beta {}'.format(beta) if beta else '',
|
f'{" validate" if validate else ""}'
|
||||||
' -betapassword {}'.format(beta_pass) if beta_pass else '',
|
f'{" -beta {}".format(beta) if beta else ""}'
|
||||||
))
|
f'{" -betapassword {}".format(beta_pass) if beta_pass else ""}'
|
||||||
|
)
|
||||||
return len(self._commands) - 1
|
return len(self._commands) - 1
|
||||||
|
|
||||||
def workshop_download_item(self, app_id: int, workshop_id: int, validate: bool = False):
|
def workshop_download_item(
|
||||||
|
self, app_id: int, workshop_id: int, validate: bool = False
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Updates/installs workshop content
|
Updates/installs workshop content
|
||||||
:param app_id: The parent application ID
|
:param app_id: The parent application ID
|
||||||
:param workshop_id: The ID for workshop content. Can be found in the url.
|
:param workshop_id: The ID for workshop content. Can be found in the url.
|
||||||
:param validate: Optional parameter for validation. Turn this on when updating something
|
:param validate: Optional. Turn this on when updating something
|
||||||
:return: Index command was added at
|
:return: Index command was added at
|
||||||
"""
|
"""
|
||||||
self._commands.append('+workshop_download_item {} {}{}'.format(
|
self._commands.append(
|
||||||
app_id,
|
f"+workshop_download_item "
|
||||||
workshop_id,
|
f"{app_id} "
|
||||||
' validate' if validate else ''
|
f"{workshop_id}"
|
||||||
))
|
f'{" validate" if validate else ""}'
|
||||||
|
)
|
||||||
return len(self._commands) - 1
|
return len(self._commands) - 1
|
||||||
|
|
||||||
def custom(self, cmd: str):
|
def custom(self, cmd: str):
|
||||||
@ -70,8 +79,7 @@ class SteamCMD_command:
|
|||||||
# Replacing with None to keep indexes intact
|
# Replacing with None to keep indexes intact
|
||||||
self._commands[idx] = None
|
self._commands[idx] = None
|
||||||
return True
|
return True
|
||||||
else:
|
return False
|
||||||
return False
|
|
||||||
|
|
||||||
def get_cmd(self):
|
def get_cmd(self):
|
||||||
params = filter(None, self._commands)
|
params = filter(None, self._commands)
|
||||||
|
Loading…
Reference in New Issue
Block a user