Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.4.0 + Linux Support #45

Merged
merged 8 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/release_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

name: Build Linux And Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
BuildAndUploadToReleaseAssets:
permissions:
contents: write
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.11

- name: Install Requirements
run: pip install -r requirements.txt

- name: Build with PyInstaller
run: pyinstaller --clean main.spec --distpath "./Myth Mod Manager"

- name: Tar Myth Mod Manager
run: tar -czvf Myth-Mod-Manager.tar.gz "./Myth Mod Manager/"

- name: Upload Myth Mod Manager to Latest Release Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: Myth-Mod-Manager.tar.gz
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ mods.ini
profiles.json
externalshortcuts.json

# Pyinstaller Output Directory
Myth Mod Manager/

# Disabled Mods Directory
disabled-mods/

Expand Down
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
As long as there's an opened issue, please take a look and send a pull request of your contribution!

There are plans to maybe even add a wiki.

## Things to know when contributing

+ `start_MMM.bat` and `start_MMM.sh` are the scripts that starts the program
+ The program auto-adjusts paths if running via script or EXE
+ If you want to compile an exe on your system, run `createEXE.bat` or `createEXE.sh`
+ Variables that are used throughout the project are stored in `constant_vars.py`
+ Please keep your code formatting consistent with the rest of the project
+ **Use the `future-update` branch when submitting commits and PRs**

## Automated Testing

To make sure everything works, before submitting a PR please run PyTest to double check your code.

PyTest doesn't cover every function yet but it covers most of it.

### How to run PyTest

1. Open your terminal and make sure your current directory is the repository
2. Execute command `python3 -m venv /venv`
+ Steps 1-2 do not have to be repeated once done
3. Start the venv via:
+ Windows: `venv/scripts/activate.bat`
+ Linux (bash/zsh): `venv/bin/activate`
4. Install/Update dependencies in the venv `pip install -r requirements.txt`
5. Execute command `pytest tests` and it should work

If you have any questions, [contact me](https://github.com/Wolfmyths) on one of my socials.
13 changes: 13 additions & 0 deletions FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: Wolfmyths
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
30 changes: 7 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A simple mod manager for PAYDAY 2 to make managing all of those files a little b

![Python](https://img.shields.io/badge/Python-3.11-blue)
![Framework](https://img.shields.io/badge/Framework-PySide6-green)
![Platform](https://img.shields.io/badge/OS-Windows-blue)
![Platform](https://img.shields.io/badge/OS-Windows_|_Linux-blue)

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/C0C4MJZS9)

Expand Down Expand Up @@ -55,14 +55,14 @@ a trojan.

Rest assured, this program does not contain malicious code.

**When a release is published, github builds the executable as seen [here](https://github.com/Wolfmyths/Myth-Mod-Manager/blob/main/.github/workflows/release.yml), not me.**
**When a release is published, github builds the executable as seen [here](https://github.com/Wolfmyths/Myth-Mod-Manager/blob/main/.github/workflows), not me.**

If you still are suspicious, you can build the executable yourself with these steps:

1. [Install Python 3.11](https://www.python.org/downloads/)
2. Clone this repository
3. Run `createEXE.bat`
4. After the `createEXE.bat` automatically closes, there will be a folder created called `Myth Mod Manager` which contains the newly compiled executable. This is created within the repository.
3. Run `createEXE.bat` or `createEXE.sh` depending on your OS
4. There will be a folder created called `Myth Mod Manager` which contains the newly compiled executable. This is created within the repository.
5. Move `Myth Mod Manager` to your preferred directory and start it.

# Supported Platforms
Expand All @@ -76,7 +76,9 @@ Windows:

Linux/MacOS:

If you are an avid Linux user you may be able to help create compadability for MacOS/Linux on [this issue here](https://github.com/Wolfmyths/Myth-Mod-Manager/issues/18)
Linux is supported, but I've only tested on Mint Linux.

Please report any issues found.

### Reguarding Storefront

Expand All @@ -91,24 +93,6 @@ You may download any version of Myth Mod Manager and view changelogs at the [rel
+ New Icon/Logo
+ Auto mod type detection
+ Muli-Language Support [See issue #44](https://github.com/Wolfmyths/Myth-Mod-Manager/issues/44)
+ Linux support
+ Some kind of [modworkshop.net](https://modworkshop.net/g/payday-2) integration, see [issue #14](https://github.com/Wolfmyths/Myth-Mod-Manager/issues/14)

*Suggestions are appreciated!*

# Contributing

As long as there's an opened issue, please take a look and send a pull request of your contribution!

There are plans to add a CONTRIBUTING.md and maybe even a wiki.

### Things to know when contributing

+ `start_MMM.bat` is the script that starts the program
+ The program auto-adjusts paths if running via script or EXE
+ If you want to compile an exe on your system, run `createEXE.bat`
+ Variables that are used throughout the project are stored in `constant_vars.py`
+ Please keep your code formatting consistent with the rest of the project
+ **Use the other branch which includes the next update when submitting commits and PRs**

If you have any questions, [contact me](https://github.com/Wolfmyths) on one of my socials.
3 changes: 2 additions & 1 deletion createEXE.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ pip install -r %Txt%
echo Running Pyinstaller
pyinstaller --clean %Spec% --distpath ./%disFolder%

echo Installation Finished!
echo Installation Finished!
pause
21 changes: 16 additions & 5 deletions main.spec
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
# -*- mode: python ; coding: utf-8 -*-
import os
import sys

block_cipher = None

DATA = [
('src\\icon.ico', '.\\src'),
('src\\graphics', '.\\src\\graphics')
(os.path.join('src', 'icon.ico'), os.path.join('.', 'src')),
(os.path.join('src', 'graphics'), os.path.join('.', 'src', 'graphics'))
]

BINARIES = []

if sys.platform.startswith('win'):
BINARIES.append(('src\\runGame.bat', '.'))

ICON = os.path.join('src', 'icon.ico')

else:
ICON = os.path.join('assets', 'icon.png')

a = Analysis(
['src\\__main__.py'],
[os.path.join('src', '__main__.py')],
pathex=[],
binaries=[('src\\runGame.bat', '.')],
binaries=BINARIES,
datas=DATA,
hiddenimports=[],
hookspath=[],
Expand All @@ -36,7 +47,7 @@ exe = EXE(
debug=False,
bootloader_ignore_signals=False,
strip=False,
icon='src\\icon.ico',
icon=ICON,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
Expand Down
70 changes: 70 additions & 0 deletions src/api/checkModUpdate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import logging

from PySide6.QtCore import QObject, QUrl, Signal
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply

from semantic_version import Version


class checkModUpdate(QObject):
'''
Instancing this object will run a series of
functions to get the latest Myth Mod Manager version.

`checkUpdate` will delete itself after it's finished.
'''

updateDetected = Signal(str)
upToDate = Signal()
error = Signal()

def __init__(self, modId: str, localVer: str) -> None:
super().__init__()
logging.getLogger(__file__)

try:
self.localVer = Version.coerce(localVer)
except Exception as e:
logging.error('checkModUpdate.__init__(), An error occured trying to parse mod local version %s:\n%s', localVer, str(e))
self.error.emit()
self.deleteLater()

link = f'https://api.modworkshop.net/mods/{modId}/version'

network = QNetworkAccessManager(self)
request = QNetworkRequest(QUrl(link))
logging.debug('Request for %s from checkModUpdate() started', link)

self.reply = network.get(request)
self.reply.finished.connect(self.__reply_handler)

def __reply_handler(self) -> None:
reply: QNetworkReply = self.sender()

if reply.error() == QNetworkReply.NetworkError.NoError:
self.__checkVersion()
else:
logging.error('Internet error in checkModUpdate():\n%s', reply.error())
self.error.emit()
self.deleteLater()

def __checkVersion(self) -> None:
reply: QNetworkReply = self.sender()

replyDecoded = reply.readAll().data().decode()

try:
latestVersion = Version.coerce(replyDecoded)
except Exception as e:
logging.error('An error occured trying to access a modworkshop.net API reply in checkModUpdate().__checkversion():\n%s', str(e))
self.error.emit()
self.deleteLater()

logging.info('Latest Version: %s', latestVersion)

if latestVersion > self.localVer:
self.updateDetected.emit(replyDecoded)
else:
self.upToDate.emit()

self.deleteLater()
3 changes: 2 additions & 1 deletion src/api/checkUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __reply_handler(self) -> None:
else:
logging.error('Internet error in checkUpdate():\n%s', reply.error())
self.error.emit()
self.deleteLater()

def __checkVersion(self) -> None:
reply: QNetworkReply = self.sender()
Expand All @@ -54,7 +55,7 @@ def __checkVersion(self) -> None:
except Exception as e:
logging.error('An error occured trying to access a Github API reply in checkUpdate().__checkversion():\n%s', str(e))
self.error.emit()
return
self.deleteLater()

if isPrerelease(VERSION):
latestVersion = Version.coerce(data[0]['tag_name'])
Expand Down
Loading