Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.4.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rlnt committed Mar 27, 2021
2 parents 221dbed + 08b0c32 commit 1d5d350
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 43 deletions.
19 changes: 15 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@ The format is based on [Keep a Changelog][keep a changelog] and this project adh

## [Unreleased]

### Added

- Export `asyncio`
- `_asyncio.pyd`, `_overlapped.pyd` to the distributed files
- /

---

## [Released]

## [0.4.1] - 2021-03-27

### Added
- `asyncio`
- `_asyncio.pyd`, `_overlapped.pyd` to the distributed files
- library version checker
- new troubleshooting page
- more exception handling

### Changed
- mod version check handling


## [0.4.0] - 2021-03-25

### Added
Expand Down Expand Up @@ -81,6 +91,7 @@ The format is based on [Keep a Changelog][keep a changelog] and this project adh
<!-- Versions -->
[unreleased]: https://github.com/RLNT/bl2_eridium/compare/v1.0.0...HEAD
[released]: https://github.com/RLNT/bl2_eridium/releases
[0.4.1]: https://github.com/RLNT/bl2_eridium/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/RLNT/bl2_eridium/compare/v0.3.2...v0.4.0
[0.3.2]: https://github.com/RLNT/bl2_eridium/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/RLNT/bl2_eridium/compare/v0.3.0...v0.3.1
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@
- `Borderlands 2\Binaries\Win32\Mods`


## **🐞 Troubleshooting**
What you can do if this website was opened automatically upon starting the game:

- make sure you installed the latest **release** from [releases]
- make sure the EridiumLib sits in the right path
- `Borderlands 2\Binaries\Win32\Mods\EridiumLib`
- make sure you have the `dist` folder within the mod directory and there are files in it
- if it's still not working, contact us on [Discord]


## **💻 Developing**
In order to work on this library, you need the latest python files from the `requirements.txt`.

Expand Down
85 changes: 57 additions & 28 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,28 @@

# isort: skip

import asyncio
import socket
import ssl
import asyncio

import requests # noqa: E402
import semver # noqa: E402
import ujson # noqo: E402


__all__ = [
"log",
"isClient",
"getCurrentPlayerController",
"checkLibraryVersion",
"getCurrentWorldInfo",
"getCurrentGameInfo",
"getSkillManager",
"getActionSkill",
"getVaultHunterClassName",
"validateVersion",
"getLatestVersion",
"isLatestRelease",
"checkLibraryVersion",
"checkModVersion",
"EridiumMod",
"keys",
"debug",
Expand All @@ -61,7 +62,7 @@
"ssl",
"asyncio",
]
__version__ = "0.4.0"
__version__ = "0.4.1"


def log(mod: SDKMod, *args: Any) -> None:
Expand Down Expand Up @@ -117,38 +118,71 @@ def getVaultHunterClassName(PC: Optional[unrealsdk.UObject] = None) -> str:
return str(PC.PlayerClass.CharacterNameId.CharacterClassId.ClassName)


def getLatestVersion(repo: str) -> str:
response = requests.get(f"https://api.github.com/repos/{repo}/releases")
response.raise_for_status()
releases = response.json()
def validateVersion(version: str) -> str:
if version[0] == "v":
version = version[1:]
return version


def getLatestVersion(repository: str) -> str:
"""
Gets the latest public release tag name of a passed in repository.
Will raise an exception if the releases couldn't be fetched.
"""
try:
response = requests.get(f"https://api.github.com/repos/{repository}/releases")
response.raise_for_status()
releases = response.json()
except Exception:
raise

if len(releases) < 1:
raise RuntimeWarning(f"{repo} has no releases")
return str(releases[0]["tag_name"])
raise RuntimeWarning(f"{repository} has no releases!")

return str(releases[0]["tag_name"])

def isLatestRelease(latest_version: str, current_version: str) -> bool:
if latest_version[0] == "v":
latest_version = latest_version[1:]
if current_version[0] == "v":
current_version = current_version[1:]

return int(semver.compare(current_version, latest_version)) >= 0
def isLatestRelease(latestVersion: str, currentVersion: str) -> bool:
"""
Returns True if the current version is equal
or higher than the latest version.
"""
return int(semver.compare(validateVersion(currentVersion), validateVersion(latestVersion))) >= 0


def checkLibraryVersion(required_version: str) -> bool:
"""Returns True if the version of EridiumLib is compatible.
Opens the download page for EridiumLib if the version is incompatible.
def checkLibraryVersion(requiredVersion: str) -> bool:
"""
Returns True if the version of EridiumLib is compatible.
If not, opens a page which informs that the EridiumLib version is incompatible.
"""
import webbrowser

if int(semver.compare(__version__, required_version)) >= 0:
if int(semver.compare(__version__, validateVersion(requiredVersion))) >= 0:
return True

webbrowser.open("https://github.com/RLNT/bl2_eridium/releases/latest")

webbrowser.open("https://github.com/RLN/bl2_eridiumT/blob/main/docs/TROUBLESHOOTING.md")
return False


def checkModVersion(mod: SDKMod, repository: str) -> None:
"""
Checks if the mod version is up-to-date.
Will log the results to the console.
"""
log(mod, f"Version: v{mod.Version}")

try:
latestVersion: str = getLatestVersion(repository)
except Exception:
log(mod, "Latest version couldn't be fetched! Skipping version check.")
return

if isLatestRelease(validateVersion(latestVersion), validateVersion(mod.Version)):
log(mod, "Mod is up-to-date!")
else:
log(mod, f"Newer version available: {latestVersion}")


class EridiumLib(SDKMod):
Name = "EridiumLib"
Author = "Chronophylos, Relentless"
Expand All @@ -166,12 +200,7 @@ class EridiumLib(SDKMod):

def __init__(self) -> None:
self.Status = "Enabled"

log(self, f"Version: {self.Version}")
try:
log(self, f"Latest release tag: {getLatestVersion('RLNT/bl2_eridium')}")
except RuntimeWarning as ex:
log(self, f"Warning: {ex}")
checkModVersion(self, "RLNT/bl2_eridium")
log(self, f"Python Version: {sys.version}")
log(self, f"__debug__: {__debug__}")

Expand Down
41 changes: 41 additions & 0 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# **🐞 Troubleshooting**

> If this site opened automatically when you started the game, it means you have an issue with your mod installation.
## **What can be the reasons for this?**
- outdated library version
- happens if a mod requests a newer version of this library
- module not found error
- means you didn't install this library at all or it's not installed correctly
- import error
- means there are functions required by a mod which are not in the library
- ususally caused by an outdated library version

## **How do I see what the reason is?**
You can usually see the error in the console of the game.

If you don't have a console, you can also take a look at the PythonSDK log which is located here:<br>
`Borderlands2\Binaries\Win32\python-sdk.log`

## **How can I fix my problem?**
- outdated library version:
- download the latest **release** from [releases] and install it
- module not found error:
- make sure you installed the EridiumLib correctly
- it has to be in the right path
- `Borderlands 2\Binaries\Win32\Mods\EridiumLib`
- the name of the mod folder is important
- import error:
- download the latest **release** from [releases] and install it
- other possible solutions:
- make sure you have the `dist` folder within the mod directory and there are files in it
- try redownloading the latest **release** from [releases] and make sure the path is correct
- make sure you didn't download the repository source code, use the release

## **I am still having problems!**
Join our [Discord] and ask for help.


<!-- Links -->
[discord]: https://discordapp.com/invite/Q3qxws6
[releases]: https://github.com/RLNT/bl2_eridium/releases
3 changes: 2 additions & 1 deletion modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"supports": ["BL2", "TPS"],
"issues": "https://github.com/RLNT/bl2_eridium/issues",
"source": "https://github.com/RLNT/bl2_eridium",
"latest": "0.4.0",
"latest": "0.4.1",
"versions": {
"0.4.1": "https://github.com/RLNT/bl2_eridium/releases/tag/v0.4.1",
"0.4.0": "https://github.com/RLNT/bl2_eridium/releases/tag/v0.4.0",
"0.3.2": "https://github.com/RLNT/bl2_eridium/releases/tag/v0.3.2"
},
Expand Down

0 comments on commit 1d5d350

Please sign in to comment.