Skip to content

Commit d8a00d5

Browse files
author
Pawel Czoppa
committed
Merge branch 'master' of https://gitlab.gog.com/galaxy-client/galaxy-plugin-api into platform_id_update
# Conflicts: # PLATFORM_IDs.md
2 parents 8d210e7 + d4cd1ce commit d8a00d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1474
-1555
lines changed

.gitlab-ci.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ test_package:
1414

1515
deploy_package:
1616
stage: deploy
17+
variables:
18+
TWINE_USERNAME: $PYPI_USERNAME
19+
TWINE_PASSWORD: $PYPI_PASSWORD
1720
script:
21+
- pip install twine wheel
22+
- rm -rf dist
1823
- export VERSION=$(python setup.py --version)
19-
- python setup.py sdist --formats=gztar upload -r gog-pypi
24+
- python setup.py sdist --formats=gztar bdist_wheel
25+
- twine upload dist/*
2026
- curl -X POST --silent --show-error --fail
2127
"https://gitlab.gog.com/api/v4/projects/${CI_PROJECT_ID}/repository/tags?tag_name=${VERSION}&ref=${CI_COMMIT_REF_NAME}&private_token=${PACKAGE_DEPLOYER_API_TOKEN}"
2228
when: manual
2329
only:
2430
- master
2531
except:
26-
- tags
32+
- tags

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dist: xenial # required for Python >= 3.7
2+
language: python
3+
python:
4+
- "3.7"
5+
install:
6+
- pip install -r requirements.txt
7+
script:
8+
- pytest

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 GOG sp. z o.o.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

PLATFORM_IDs.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ Platform ID list for GOG Galaxy 2.0 Integrations
7979
| psvita | PlayStation Vita |
8080
| nds | Nintendo DS |
8181
| 3ds | Nintendo 3DS |
82+
| pathofexile | Path of Exile |

README.md

+24-18
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
# GOG Galaxy Integrations Python API
22

3-
This Python library allows to easily build community integrations for various gaming platforms with GOG Galaxy 2.0.
3+
This Python library allows developers to easily build community integrations for various gaming platforms with GOG Galaxy 2.0.
44

55
- refer to our <a href='https://galaxy-integrations-python-api.readthedocs.io'>documentation</a>
66

77
## Features
88

9-
Each integration in GOG Galaxy 2.0 comes as a separate Python script, and is launched as a separate process, that which needs to communicate with main instance of GOG Galaxy 2.0.
9+
Each integration in GOG Galaxy 2.0 comes as a separate Python script and is launched as a separate process that needs to communicate with the main instance of GOG Galaxy 2.0.
1010

1111
The provided features are:
1212

13-
- multistep authorisation using a browser built into GOG Galaxy 2.0
13+
- multistep authorization using a browser built into GOG Galaxy 2.0
1414
- support for GOG Galaxy 2.0 features:
15-
- importing owned and detecting installed games
16-
- installing and launching games
17-
- importing achievements and game time
18-
- importing friends lists and statuses
19-
- importing friends recomendations list
20-
- receiving and sending chat messages
15+
- importing owned and detecting installed games
16+
- installing and launching games
17+
- importing achievements and game time
18+
- importing friends lists and statuses
19+
- importing friends recommendations list
20+
- receiving and sending chat messages
2121
- cache storage
2222

2323
## Platform Id's
2424

2525
Each integration can implement only one platform. Each integration must declare which platform it's integrating.
2626

27-
[List of possible Platofrm IDs](PLATFORM_IDs.md)
27+
[List of possible Platform IDs](PLATFORM_IDs.md)
2828

2929
## Basic usage
3030

31-
Eeach integration should inherit from the :class:`~galaxy.api.plugin.Plugin` class. Supported methods like :meth:`~galaxy.api.plugin.Plugin.get_owned_games` should be overwritten - they are called from the GOG Galaxy client in the appropriate times.
32-
Each of those method can raise exceptions inherited from the :exc:`~galaxy.api.jsonrpc.ApplicationError`.
31+
Each integration should inherit from the :class:`~galaxy.api.plugin.Plugin` class. Supported methods like :meth:`~galaxy.api.plugin.Plugin.get_owned_games` should be overwritten - they are called from the GOG Galaxy client at the appropriate times.
32+
Each of those methods can raise exceptions inherited from the :exc:`~galaxy.api.jsonrpc.ApplicationError`.
3333
Communication between an integration and the client is also possible with the use of notifications, for example: :meth:`~galaxy.api.plugin.Plugin.update_local_game_status`.
3434

3535
```python
@@ -61,11 +61,13 @@ if __name__ == "__main__":
6161

6262
## Deployment
6363

64-
The client has a built-in Python 3.7 interpreter, so the integrations are delivered as python modules.
65-
In order to be found by GOG Galaxy 2.0 an integration folder should be placed in [lookup directory](#deploy-location). Beside all the python files, the integration folder has to contain [manifest.json](#deploy-manifest) and all third-party dependencies. See an [examplary structure](#deploy-structure-example).
64+
The client has a built-in Python 3.7 interpreter, so integrations are delivered as Python modules.
65+
In order to be found by GOG Galaxy 2.0 an integration folder should be placed in [lookup directory](#deploy-location). Beside all the Python files, the integration folder must contain [manifest.json](#deploy-manifest) and all third-party dependencies. See an [exemplary structure](#deploy-structure-example).
6666

6767
### Lookup directory
68+
6869
<a name="deploy-location"></a>
70+
6971
- Windows:
7072

7173
`%localappdata%\GOG.com\Galaxy\plugins\installed`
@@ -75,8 +77,9 @@ In order to be found by GOG Galaxy 2.0 an integration folder should be placed in
7577
`~/Library/Application Support/GOG.com/Galaxy/plugins/installed`
7678

7779
### Manifest
78-
<a name="deploy-manifest"></a>
79-
Obligatory JSON file to be placed in a integration folder.
80+
81+
<a name="deploy-manifest"></a>
82+
Obligatory JSON file to be placed in an integration folder.
8083

8184
```json
8285
{
@@ -91,6 +94,7 @@ Obligatory JSON file to be placed in a integration folder.
9194
"script": "plugin.py"
9295
}
9396
```
97+
9498
| property | description |
9599
|---------------|---|
96100
| `guid` | |
@@ -99,13 +103,15 @@ Obligatory JSON file to be placed in a integration folder.
99103
| `script` | path of the entry point module, relative to the integration folder |
100104

101105
### Dependencies
102-
All third-party packages (packages not included in Python 3.7 standard library) should be deployed along with plugin files. Use the folowing command structure:
106+
107+
All third-party packages (packages not included in the Python 3.7 standard library) should be deployed along with plugin files. Use the following command structure:
103108

104109
```pip install DEP --target DIR --implementation cp --python-version 37```
105110

106-
For example plugin that uses *requests* has structure as follows:
111+
For example, a plugin that uses *requests* could have the following structure:
107112

108113
<a name="deploy-structure-example"></a>
114+
109115
```bash
110116
installed
111117
└── my_integration

docs/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
# List of patterns, relative to source directory, that match files and
4848
# directories to ignore when looking for source files.
4949
# This pattern also affects html_static_path and html_extra_path.
50-
exclude_patterns = []
50+
exclude_patterns = [] # type: ignore
5151

5252

5353
# -- Options for HTML output -------------------------------------------------

jenkins/release.groovy

-14
This file was deleted.

jenkins/release.py

-26
This file was deleted.

jenkins/requirements.txt

-1
This file was deleted.

mypy.ini

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mypy]
2+
ignore_missing_imports = True

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
addopts = --flakes
2+
addopts = --flakes --mypy

requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
pytest==4.2.0
33
pytest-asyncio==0.10.0
44
pytest-mock==1.10.3
5+
pytest-mypy==0.3.2
56
pytest-flakes==4.0.0
67
# because of pip bug https://github.com/pypa/pip/issues/4780
78
aiohttp==3.5.4
8-
certifi==2019.3.9
9+
certifi==2019.3.9
10+
psutil==5.6.3; sys_platform == 'darwin'

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="galaxy.plugin.api",
5-
version="0.36",
5+
version="0.47",
66
description="GOG Galaxy Integrations Python API",
77
author='Galaxy team',
88
author_email='[email protected]',

src/galaxy/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__: str = __import__('pkgutil').extend_path(__path__, __name__)

src/galaxy/api/consts.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Platform(Enum):
8080
PlayStationVita = "psvita"
8181
NintendoDs = "nds"
8282
Nintendo3Ds = "3ds"
83+
PathOfExile = "pathofexile"
8384

8485
class Feature(Enum):
8586
"""Possible features that can be implemented by an integration.
@@ -97,6 +98,8 @@ class Feature(Enum):
9798
ImportUsers = "ImportUsers"
9899
VerifyGame = "VerifyGame"
99100
ImportFriends = "ImportFriends"
101+
ShutdownPlatformClient = "ShutdownPlatformClient"
102+
LaunchPlatformClient = "LaunchPlatformClient"
100103

101104

102105
class LicenseType(Enum):
@@ -115,11 +118,3 @@ class LocalGameState(Flag):
115118
None_ = 0
116119
Installed = 1
117120
Running = 2
118-
119-
120-
class PresenceState(Enum):
121-
""""Possible states that a user can be in."""
122-
Unknown = "Unknown"
123-
Online = "online"
124-
Offline = "offline"
125-
Away = "away"

src/galaxy/api/errors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from galaxy.api.jsonrpc import ApplicationError, UnknownError
22

3-
UnknownError = UnknownError
3+
assert UnknownError
44

55
class AuthenticationRequired(ApplicationError):
66
def __init__(self, data=None):

src/galaxy/api/jsonrpc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import inspect
66
import json
77

8+
from galaxy.reader import StreamLineReader
9+
810
class JsonRpcError(Exception):
911
def __init__(self, code, message, data=None):
1012
self.code = code
@@ -67,7 +69,7 @@ def anonymise_sensitive_params(params, sensitive_params):
6769
class Server():
6870
def __init__(self, reader, writer, encoder=json.JSONEncoder()):
6971
self._active = True
70-
self._reader = reader
72+
self._reader = StreamLineReader(reader)
7173
self._writer = writer
7274
self._encoder = encoder
7375
self._methods = {}
@@ -114,6 +116,7 @@ async def run(self):
114116
data = data.strip()
115117
logging.debug("Received %d bytes of data", len(data))
116118
self._handle_input(data)
119+
await asyncio.sleep(0) # To not starve task queue
117120

118121
def stop(self):
119122
self._active = False

0 commit comments

Comments
 (0)