Repository cleanup

This commit is contained in:
Wiktor Mazur
2019-10-20 14:59:45 +02:00
parent a15f7ae92c
commit e14dbf66dc
36 changed files with 180 additions and 102 deletions
+9
View File
@@ -4,5 +4,14 @@ lib/**/target
damage-meter.log
*.so
.vscode
# Python
*.spec
env
**/build
**/dist
**/*.egg-info
*.egg
__pycache__
albion-online-stats.cfg
+26 -29
View File
@@ -1,6 +1,7 @@
<p align="center">
<img src="assets/albion-stats-icon.png" width="100">
</p>
<img src="https://ci.appveyor.com/api/projects/status/github/albion-online-stats" alt="Project Badge">
Albion Online Stats
===================
@@ -21,6 +22,8 @@ Albion online stats is an extension to MMORPG game - Albion Online. It tracks ne
# Usage of built release
> **Note** this section does not require any coding knowledge. Those simple two steps are required to use this software :)
## Installation
1. On windows make sure that WinPcap is installed in your system. [Npcap 0.9983 installer for Windows Vista/2008, 7/2008R2, 8/2012, 8.1/2012R2, 10/2016 (x86 and x64)](https://nmap.org/npcap/dist/npcap-0.9983.exe)
@@ -39,45 +42,39 @@ After first execution the app is going to create default configuration file name
- Python installed
- *Windows only prerequisites* https://github.com/libpnet/libpnet#windows
## All platforms
1. Clone repository:
```shell
git clone https://github.com/mazurwiktor/albion-online-stats.git
```
2. Build rust library
2. [optional] Create and activate python virtualenv
```shell
cargo build --release
python -m venv env
[linux/mac] . env/bin/activate
[windows] .\env\Scripts\activate.ps1
```
3. Install requirements (backend will be compiled during requirements installation)
```shell
pip install -v -r frontend/requirements.txt
```
4. Run the application
```shell
[sudo on linux] python frontend/aostats.py
```
## GUI testing
- Seting TESTING variable runs frontend without backend dependency
```shell
TESTING=true python frontend/aostats.py
```
3. Copy library to GUI directory
3.1 on Linux
```shell
cp target/release/libmeter.so gui/
```
3.1 on Windows
```shell
cp target/release/meter.dll gui/libmeter.pyd
```
4. Run GUI
3.1 on Linux
```shell
sudo python gui/meter.py
```
3.1 on Windows
```shell
python gui/meter.py
```
# License
+14 -12
View File
@@ -6,15 +6,18 @@ environment:
RUST_CHANNEL: beta
WPD_LIB_PATH: "C:/dl/wpdpack/WpdPack/Lib/x64/Packet.lib"
PYTHON: "C:\\Python36-x64"
PYTHON_LIB: "C:\\Python36-x64\\libs\\python36.lib"
PYTHON_ARCH: "64"
VCVARS: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\vcvars64.bat"
install:
- ps: ls C:\\Python36-x64
- SET PATH=%PYTHON%;%path%
- ps: mkdir C:/dl
- curl -o "C:/dl/wpd.zip" "https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip"
- ps: Add-Type -AssemblyName system.io.compression.filesystem
- ps: "[io.compression.zipfile]::ExtractToDirectory(\"C:/dl/wpd.zip\", \"C:/dl/wpdpack\")"
- ps: cp ${env:WPD_LIB_PATH} "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64"
- ps: cp ${env:PYTHON_LIB} "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64"
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:RUST_CHANNEL}-${env:TARGET}.exe"
- rust-%RUST_CHANNEL%-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
- CALL "%VCVARS%"
@@ -22,21 +25,20 @@ install:
- choco install winpcap
- rustc -V
- cargo -V
test: false
test: true
test_script:
- ps: cd backend
- cargo test
- ps: cd ..
build_script:
- cargo build --release --verbose
- python -m venv env
- ps: .\env\Scripts\activate.ps1
- pip install -v -r frontend\requirements.txt
- pyinstaller -F -w -i assets\albion-stats-icon.ico frontend\aostats.py
- ps: deactivate
after_build:
- ps: cd ${env:APPVEYOR_BUILD_FOLDER}/gui
- python -m venv env
- ps: .\env\Scripts\activate.ps1
- pip install -r requirements.txt
- ps: cd src
- ps: cp ${env:APPVEYOR_BUILD_FOLDER}\target\release\meter.dll libmeter.pyd
- pyinstaller -F -w -i ..\..\assets\albion-stats-icon.ico meter.py
- ps: deactivate
- ps: mv dist\meter.exe ..\..\albion-online-stats.exe
- ps: mv dist\aostats.exe albion-online-stats.exe
- ps: ls
- ps: ls ..\
artifacts:
path: albion-online-stats.exe
name: binary
+62 -26
View File
@@ -8,6 +8,30 @@ dependencies = [
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "aho-corasick"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "aostats"
version = "0.1.0"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cpython 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fake_clock 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"packet_sniffer 0.1.0",
"photon_protocol 0.1.0",
"simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"timer 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "arrayref"
version = "0.3.5"
@@ -332,22 +356,6 @@ dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "meter"
version = "0.1.0"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cpython 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fake_clock 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"packet_sniffer 0.1.0",
"photon_protocol 0.1.0",
"simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"timer 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nodrop"
version = "0.1.13"
@@ -474,10 +482,10 @@ dependencies = [
[[package]]
name = "pnet_macros"
version = "0.22.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex 0.42.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -497,7 +505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"pnet_base 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pnet_macros 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pnet_macros 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pnet_macros_support 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex 0.42.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -537,7 +545,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.61 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -612,19 +620,38 @@ dependencies = [
[[package]]
name = "regex"
version = "1.0.6"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
version = "0.6.11"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -814,6 +841,11 @@ dependencies = [
"chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ucd-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.0.3"
@@ -869,6 +901,7 @@ dependencies = [
[metadata]
"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba"
"checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b"
@@ -922,7 +955,7 @@ dependencies = [
"checksum pnet 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63d693c84430248366146e3181ff9d330243464fa9e6146c372b2f3eb2e2d8e7"
"checksum pnet_base 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4df28acf2fcc77436dd2b91a9a0c2bb617f9ca5f2acefee1a4135058b9f9801f"
"checksum pnet_datalink 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b34f8ca857599d05b6b082e9baff8d27c54cb9c26568cf3c0993a5755816966"
"checksum pnet_macros 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f16d1fa7fd0edebc36055587b8b5af8a109bbc29a55fb484a37e2029b971a7"
"checksum pnet_macros 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d228096fd739d4e3e60dee9e1e4f07d9ae0f3f309c876834192538748e561e4"
"checksum pnet_macros_support 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84684f2cddefc37a06f2fe2ca4dcc3457fc3b282734b5246507d8ee75d2780ae"
"checksum pnet_packet 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a6cdcdaddc5174f18286298842a4e31cd3cc018933d42af51434b1fa07dcbe"
"checksum pnet_sys 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "682b2eca84cc440bce8336813f78eb6d3cb0fed89fe0e87ae22acfca8363f176"
@@ -937,8 +970,10 @@ dependencies = [
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
"checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d"
"checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467"
"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f"
"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
"checksum rust-argon2 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81ed8d04228b44a740c8d46ff872a28e50fff3d659f307ab4da2cc502e019ff3"
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
@@ -962,6 +997,7 @@ dependencies = [
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
"checksum timer 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a9522a9ec40055e2f9e514e38d2415a496e81dbfc1ece15d98d2fe55c44946b3"
"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874"
"checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba"
+2 -2
View File
@@ -1,5 +1,5 @@
[package]
name = "meter"
name = "libaostats"
version = "0.1.0"
authors = ["Wiktor Mazur <wiktormazur1@gmail.com>"]
edition = "2018"
@@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "meter"
name = "libaostats"
crate-type = ["dylib"]
[dependencies.cpython]
+1
View File
@@ -0,0 +1 @@
from libaostats import *
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env python
import sys
from setuptools import setup
try:
from setuptools_rust import RustExtension, Binding
except ImportError:
import subprocess
errno = subprocess.call([sys.executable, "-m", "pip", "install", "setuptools-rust"])
if errno:
print("Please install setuptools-rust package")
raise SystemExit(errno)
else:
from setuptools_rust import RustExtension, Binding
setup_requires = ["setuptools-rust>=0.10.1", "wheel"]
install_requires = []
setup(
name="aostats",
packages=["aostats"],
rust_extensions=[RustExtension("libaostats", 'Cargo.toml', binding=Binding.RustCPython)],
install_requires=install_requires,
setup_requires=setup_requires,
include_package_data=True,
zip_safe=False,
)
View File
+1 -2
View File
@@ -160,8 +160,7 @@ fn initialize(_py: Python, skip_non_party_members: bool) -> PyResult<u32> {
Ok(0)
}
py_module_initializer!(libmeter, initliblibmeter, PyInit_libmeter, |py, m| {
py_module_initializer!(libaostats, initlibaostats, PyInit_libaostats, |py, m| {
m.add(py, "__doc__", "This module is implemented in Rust")?;
m.add(py, "initialize", py_fn!(py, initialize(skip_non_party_members: bool)))?;
m.add(py, "stats", py_fn!(py, stats(stat_type: StatType)))?;
+3
View File
@@ -0,0 +1,3 @@
if __name__ == "__main__":
from src import run
run()
@@ -3,3 +3,4 @@ pyinstaller
clipboard
toml~=0.10
requests~=2.22
./backend
+2
View File
@@ -0,0 +1,2 @@
from .app import run
+12 -9
View File
@@ -1,18 +1,21 @@
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath('__file__')))
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QApplication
from PySide2.QtWidgets import QMessageBox
import libmeter
from .config import config
from .main import MainWidget
from .engine import initialize
from .styling import style
from .version import current_version as get_current_version
from .version import latest_version as get_latest_version
from .version import latest_url
from config import config
from main import MainWidget
from engine import initialize
from styling import style
from version import current_version, latest_version, latest_url
if __name__ == "__main__":
def run():
initialize()
conf = config()
window_config = conf['window']
@@ -37,7 +40,7 @@ if __name__ == "__main__":
widget.setWindowFlag(Qt.FramelessWindowHint)
widget.show()
current_version, latest_version = (current_version(), latest_version())
current_version, latest_version = (get_current_version(), get_latest_version())
if latest_version and current_version != latest_version:
msg = QMessageBox()
+11 -10
View File
@@ -1,7 +1,8 @@
import os
import libmeter
from config import config
import aostats
from .config import config
TESTING_ENABLED = bool(os.getenv('TESTING'))
@@ -67,7 +68,7 @@ def zone_stats():
{'player': 'D'*20, 'damage': 0, 'time_in_combat': 12.0, 'dps': 0}
]
else:
session = libmeter.stats(StatType.Zone)
session = aostats.stats(StatType.Zone)
return stats(session)
@@ -79,7 +80,7 @@ def overall_stats():
'time_in_combat': 12.0, 'dps': 12.4234},
]
else:
session = libmeter.stats(StatType.Overall)
session = aostats.stats(StatType.Overall)
return stats(session)
@@ -91,7 +92,7 @@ def last_fight_stats():
'time_in_combat': 12.0, 'dps': 12.4234},
]
else:
session = libmeter.stats(StatType.LastFight)
session = aostats.stats(StatType.LastFight)
return stats(session)
@@ -99,23 +100,23 @@ def get_party_members():
if TESTING_ENABLED:
return ['a', 'b', 'c']
else:
return libmeter.get_players_in_party()
return aostats.get_players_in_party()
def reset_zone_stats():
libmeter.reset(StatType.Zone)
aostats.reset(StatType.Zone)
def reset_last_fight_stats():
libmeter.reset(StatType.LastFight)
aostats.reset(StatType.LastFight)
def reset_stats():
libmeter.reset(StatType.Overall)
aostats.reset(StatType.Overall)
def initialize():
if TESTING_ENABLED:
return
cfg = config()
try:
libmeter.initialize(cfg['app']['skip_non_party_players'])
aostats.initialize(cfg['app']['skip_non_party_players'])
except:
pass
+3 -3
View File
@@ -12,9 +12,9 @@ from PySide2.QtWidgets import QComboBox
import clipboard
from table import Table
import about
import engine
from .table import Table
from . import about
from . import engine
class Mode:
CURRENT_ZONE = 'Statistics: Current zone'
@@ -1,4 +1,4 @@
from config import config
from .config import config
cfg = config()
font_size = cfg['window']['font-size']
-3
View File
@@ -1,3 +0,0 @@
#/bin/bash
python $(dirname "$0")/src/meter.py
-3
View File
@@ -1,3 +0,0 @@
pyside2~=5.13
pyinstaller
clipboard