Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
05bfdcfa92 | |||
58f82c29b9 | |||
6d653c3508 | |||
5718099d5a | |||
d2af6b90e4 | |||
1a76ca59d4 | |||
ceb3e2c660 | |||
59619ca8bf |
7 changed files with 133 additions and 43 deletions
12
.github/dependabot.yaml
vendored
Normal file
12
.github/dependabot.yaml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/"
|
||||||
|
target-branch: "develop"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
target-branch: "develop"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
35
.github/workflows/create-release.yaml
vendored
Normal file
35
.github/workflows/create-release.yaml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
name: Create release on tag push
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'release/*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Pre-compile for Windows
|
||||||
|
runs-on: windows-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.10'
|
||||||
|
|
||||||
|
- name: Make exe
|
||||||
|
run: make exe
|
||||||
|
|
||||||
|
- name: Create .zip archive
|
||||||
|
run: make release
|
||||||
|
|
||||||
|
- name: Draft release
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "elite-scripts.zip"
|
||||||
|
bodyFile: "CHANGELOG.md"
|
||||||
|
draft: true
|
20
CHANGELOG.md
20
CHANGELOG.md
|
@ -1,15 +1,29 @@
|
||||||
|
# devel
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
* `spansh.py`: `--raw` option. Prints the raw JSON returned from a query.
|
||||||
|
* `spansh.py`: `--nofeet` option for `outdatedstations`. Excludes Odyssey
|
||||||
|
settlements from the result set.
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
* `spansh.py`: Now uses <https://spansh.uk> instead of <https://spansh.co.uk>.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
# 0.7 (2021-01-28)
|
# 0.7 (2021-01-28)
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
* spansh.py: Fleet carriers are now explicitly excluded from the outdated
|
* `spansh.py`: Fleet carriers are now explicitly excluded from the outdated
|
||||||
stations list.
|
stations list.
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
* explorationtools.py: Searching for a CMDR with public profile, but hidden
|
* `explorationtools.py`: Searching for a CMDR with public profile, but hidden
|
||||||
activity will no longer error out.
|
activity will no longer error out.
|
||||||
* explorationtools.py: Searching for a CMDR with public profile, but hidden
|
* `explorationtools.py`: Searching for a CMDR with public profile, but hidden
|
||||||
flight log will no longer error out.
|
flight log will no longer error out.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
14
Makefile
14
Makefile
|
@ -12,12 +12,12 @@ docs:
|
||||||
exe:
|
exe:
|
||||||
pip install --user --upgrade -r requirements.txt
|
pip install --user --upgrade -r requirements.txt
|
||||||
pip install --user --upgrade -r pyEDSM\requirements.txt
|
pip install --user --upgrade -r pyEDSM\requirements.txt
|
||||||
python -OO -m PyInstaller --clean -yF edsm-getnearest.py
|
pip install --user --upgrade pywin32-ctypes cffi
|
||||||
python -OO -m PyInstaller --clean -yF edts.py
|
pip install --user --upgrade pyinstaller
|
||||||
python -OO -m PyInstaller --clean -yF explorationtools.py
|
python -m PyInstaller --clean -yF edsm-getnearest.py
|
||||||
python -OO -m PyInstaller --clean -yF spansh.py
|
python -m PyInstaller --clean -yF edts.py
|
||||||
|
python -m PyInstaller --clean -yF explorationtools.py
|
||||||
|
python -m PyInstaller --clean -yF spansh.py
|
||||||
|
|
||||||
# probably won’t work unless you’re me :)
|
|
||||||
release: clean
|
release: clean
|
||||||
rsync -avz gezocks:/mnt/d/git/elite-scripts/dist/ build/
|
pwsh -Command "Compress-Archive -Path .\dist\*.exe elite-scripts.zip"
|
||||||
cd build && zip -r ../$(zipfile) *
|
|
||||||
|
|
32
README.md
32
README.md
|
@ -36,7 +36,7 @@ positional arguments:
|
||||||
CMDR a list of CMDR names (must have their location public on
|
CMDR a list of CMDR names (must have their location public on
|
||||||
EDSM!)
|
EDSM!)
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--system SYSTEM the target system (must be in EDDN!)
|
--system SYSTEM the target system (must be in EDDN!)
|
||||||
--short short output (only makes sense with `--text`)
|
--short short output (only makes sense with `--text`)
|
||||||
|
@ -51,7 +51,7 @@ usage: edts.py [-h] {coords} ...
|
||||||
|
|
||||||
Script for interfacing with Alot’s hosted EDTS API.
|
Script for interfacing with Alot’s hosted EDTS API.
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
|
|
||||||
subcommands:
|
subcommands:
|
||||||
|
@ -66,7 +66,7 @@ usage: edts.py coords [-h] [--maxuncertainty [MAXUNCERTAINTY]] system
|
||||||
positional arguments:
|
positional arguments:
|
||||||
system the system name to get coordinates for
|
system the system name to get coordinates for
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--maxuncertainty [MAXUNCERTAINTY]
|
--maxuncertainty [MAXUNCERTAINTY]
|
||||||
maximum accepted uncertainty, if any
|
maximum accepted uncertainty, if any
|
||||||
|
@ -81,7 +81,7 @@ usage: explorationtools.py [-h]
|
||||||
|
|
||||||
A collection of tools useful for exploration.
|
A collection of tools useful for exploration.
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
|
|
||||||
subcommands:
|
subcommands:
|
||||||
|
@ -111,7 +111,7 @@ usage: explorationtools.py bodycount [-h] system
|
||||||
positional arguments:
|
positional arguments:
|
||||||
system system to query
|
system system to query
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ usage: explorationtools.py distancebetween [-h] [--roundto [ROUNDTO]]
|
||||||
positional arguments:
|
positional arguments:
|
||||||
system the systems to measure
|
system the systems to measure
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--roundto [ROUNDTO] the number of digits to round to (default: 2)
|
--roundto [ROUNDTO] the number of digits to round to (default: 2)
|
||||||
```
|
```
|
||||||
|
@ -135,7 +135,7 @@ positional arguments:
|
||||||
name the commander in question
|
name the commander in question
|
||||||
apikey the commander’s EDSM API key. Can be empty for public profiles.
|
apikey the commander’s EDSM API key. Can be empty for public profiles.
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--system output the commander’s last known system (default)
|
--system output the commander’s last known system (default)
|
||||||
--coords output the commander’s last known position in {x,y,z}
|
--coords output the commander’s last known position in {x,y,z}
|
||||||
|
@ -149,7 +149,7 @@ usage: explorationtools.py findsystem [-h] system
|
||||||
positional arguments:
|
positional arguments:
|
||||||
system the system in question
|
system the system in question
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -159,19 +159,20 @@ usage: explorationtools.py systemlist [-h] partialsystem
|
||||||
positional arguments:
|
positional arguments:
|
||||||
partialsystem the partial system name to query against
|
partialsystem the partial system name to query against
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
```
|
```
|
||||||
|
|
||||||
### spansh.py ###
|
### spansh.py ###
|
||||||
|
|
||||||
```
|
```
|
||||||
usage: spansh.py [-h] {nearestsystem,oldstations,systemexists} ...
|
usage: spansh.py [-h] [--raw] {nearestsystem,oldstations,systemexists} ...
|
||||||
|
|
||||||
Script for interfacing with Spansh’s API.
|
Script for interfacing with Spansh’s API.
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
|
--raw output raw json (mostly for debugging)
|
||||||
|
|
||||||
subcommands:
|
subcommands:
|
||||||
{nearestsystem,oldstations,systemexists}
|
{nearestsystem,oldstations,systemexists}
|
||||||
|
@ -191,7 +192,7 @@ usage: spansh.py nearestsystem [-h] [--short | --parsable]
|
||||||
positional arguments:
|
positional arguments:
|
||||||
coordinate the coordinates to search for (order: x, y, z)
|
coordinate the coordinates to search for (order: x, y, z)
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--short short output format (system name only)
|
--short short output format (system name only)
|
||||||
--parsable parsable output format (<name>|<x>,<y>,<z>|<distance>)
|
--parsable parsable output format (<name>|<x>,<y>,<z>|<distance>)
|
||||||
|
@ -199,9 +200,9 @@ optional arguments:
|
||||||
|
|
||||||
```
|
```
|
||||||
usage: spansh.py oldstations [-h] [--system [SYSTEM]] [--count [COUNT]]
|
usage: spansh.py oldstations [-h] [--system [SYSTEM]] [--count [COUNT]]
|
||||||
[--minage [MINAGE]] [--short]
|
[--minage [MINAGE]] [--short] [--nofeet]
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--system [SYSTEM] a single system to query. If not present, get the oldest
|
--system [SYSTEM] a single system to query. If not present, get the oldest
|
||||||
stations overall.
|
stations overall.
|
||||||
|
@ -209,6 +210,7 @@ optional arguments:
|
||||||
--minage [MINAGE] minimum age of data (in days) to be considered
|
--minage [MINAGE] minimum age of data (in days) to be considered
|
||||||
“outdated”. Defaults to 365 (= 1 year).
|
“outdated”. Defaults to 365 (= 1 year).
|
||||||
--short short output format (system/station names only)
|
--short short output format (system/station names only)
|
||||||
|
--nofeet omit Odyssey settlements
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -217,7 +219,7 @@ usage: spansh.py systemexists [-h] system
|
||||||
positional arguments:
|
positional arguments:
|
||||||
system the system to search for
|
system the system to search for
|
||||||
|
|
||||||
optional arguments:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
2
pyEDSM
2
pyEDSM
|
@ -1 +1 @@
|
||||||
Subproject commit da044e918fe17cf18d2b2e18d60ce16a168ea70b
|
Subproject commit 240ada35f78bec7490f6333a227fd8ae80a5c437
|
55
spansh.py
55
spansh.py
|
@ -23,7 +23,7 @@ def querystations(url, params):
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
|
|
||||||
def getNearestSystem(coords):
|
def getNearestSystem(coords, raw=False):
|
||||||
params = {
|
params = {
|
||||||
"x": coords[0],
|
"x": coords[0],
|
||||||
"y": coords[1],
|
"y": coords[1],
|
||||||
|
@ -35,6 +35,8 @@ def getNearestSystem(coords):
|
||||||
|
|
||||||
json = response.json()
|
json = response.json()
|
||||||
|
|
||||||
|
if raw: return json
|
||||||
|
|
||||||
ret = None
|
ret = None
|
||||||
system = json["system"]
|
system = json["system"]
|
||||||
if args.short:
|
if args.short:
|
||||||
|
@ -49,7 +51,7 @@ def getNearestSystem(coords):
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def getOldStations():
|
def getOldStations(raw=False):
|
||||||
params = {
|
params = {
|
||||||
"json": JSON.dumps({
|
"json": JSON.dumps({
|
||||||
"filters": FILTERS,
|
"filters": FILTERS,
|
||||||
|
@ -59,6 +61,8 @@ def getOldStations():
|
||||||
}
|
}
|
||||||
json = querystations(APIURLS["stations"], params)
|
json = querystations(APIURLS["stations"], params)
|
||||||
|
|
||||||
|
if raw: return json
|
||||||
|
|
||||||
ret = ""
|
ret = ""
|
||||||
for station in json["results"]:
|
for station in json["results"]:
|
||||||
if args.short:
|
if args.short:
|
||||||
|
@ -69,7 +73,7 @@ def getOldStations():
|
||||||
|
|
||||||
return ret[:-1]
|
return ret[:-1]
|
||||||
|
|
||||||
def getOldStationsInSystem(system):
|
def getOldStationsInSystem(system, raw=False):
|
||||||
FILTERS.update(system_name={"value": system})
|
FILTERS.update(system_name={"value": system})
|
||||||
params = {
|
params = {
|
||||||
"json": JSON.dumps({
|
"json": JSON.dumps({
|
||||||
|
@ -79,12 +83,12 @@ def getOldStationsInSystem(system):
|
||||||
}
|
}
|
||||||
json = querystations(APIURLS["stations"], params)
|
json = querystations(APIURLS["stations"], params)
|
||||||
|
|
||||||
|
if raw: return json
|
||||||
|
|
||||||
ret = ""
|
ret = ""
|
||||||
# exclude carriers
|
if len(json["results"]) == 0:
|
||||||
stations = list(filter(lambda station: not station["type"] == "Drake-Class Carrier", json["results"]))
|
|
||||||
if len(stations) == 0:
|
|
||||||
raise NotFoundError()
|
raise NotFoundError()
|
||||||
for station in stations:
|
for station in json["results"]:
|
||||||
# systems including the given name as a word will also trigger;
|
# systems including the given name as a word will also trigger;
|
||||||
# looking for e.g. “Mari” will also give you stuff in “Mac Mari”!
|
# looking for e.g. “Mari” will also give you stuff in “Mac Mari”!
|
||||||
if station["system_name"] == system:
|
if station["system_name"] == system:
|
||||||
|
@ -96,7 +100,7 @@ def getOldStationsInSystem(system):
|
||||||
|
|
||||||
return ret[:-1]
|
return ret[:-1]
|
||||||
|
|
||||||
def systemExists(system):
|
def systemExists(system, raw=False):
|
||||||
params = {
|
params = {
|
||||||
"json": JSON.dumps({
|
"json": JSON.dumps({
|
||||||
"filters": {
|
"filters": {
|
||||||
|
@ -111,6 +115,9 @@ def systemExists(system):
|
||||||
raise ServerError(url, params)
|
raise ServerError(url, params)
|
||||||
|
|
||||||
json = response.json()
|
json = response.json()
|
||||||
|
|
||||||
|
if raw: return json
|
||||||
|
|
||||||
if json["count"] == 0:
|
if json["count"] == 0:
|
||||||
raise NotFoundError()
|
raise NotFoundError()
|
||||||
|
|
||||||
|
@ -125,6 +132,8 @@ def systemExists(system):
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Script for interfacing with "
|
parser = argparse.ArgumentParser(description="Script for interfacing with "
|
||||||
+ "Spansh’s API.")
|
+ "Spansh’s API.")
|
||||||
|
parser.add_argument("--raw", action='store_true',
|
||||||
|
help="output raw json (mostly for debugging)")
|
||||||
subparsers = parser.add_subparsers(title="subcommands", help="sub-command help",
|
subparsers = parser.add_subparsers(title="subcommands", help="sub-command help",
|
||||||
dest="subcommand", required=True)
|
dest="subcommand", required=True)
|
||||||
|
|
||||||
|
@ -150,6 +159,8 @@ parser_oldstations.add_argument("--minage", nargs="?", type=int, default=365,
|
||||||
+ "365 (= 1 year).")
|
+ "365 (= 1 year).")
|
||||||
parser_oldstations.add_argument("--short", action='store_true',
|
parser_oldstations.add_argument("--short", action='store_true',
|
||||||
help="short output format (system/station names only)")
|
help="short output format (system/station names only)")
|
||||||
|
parser_oldstations.add_argument("--nofeet", action='store_true',
|
||||||
|
help="omit Odyssey settlements")
|
||||||
|
|
||||||
parser_systemexists = subparsers.add_parser("systemexists",
|
parser_systemexists = subparsers.add_parser("systemexists",
|
||||||
help="Checks if a given system exists in the search database.")
|
help="Checks if a given system exists in the search database.")
|
||||||
|
@ -162,9 +173,9 @@ args = parser.parse_args()
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
|
|
||||||
APIURLS = {
|
APIURLS = {
|
||||||
"nearest": "https://spansh.co.uk/api/nearest",
|
"nearest": "https://spansh.uk/api/nearest",
|
||||||
"stations": "https://spansh.co.uk/api/stations/search",
|
"stations": "https://spansh.uk/api/stations/search",
|
||||||
"systems": "https://spansh.co.uk/api/systems/search",
|
"systems": "https://spansh.uk/api/systems/search",
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -179,6 +190,20 @@ try:
|
||||||
(datetime.now() - timedelta(days=args.minage)).strftime("%Y-%m-%d")
|
(datetime.now() - timedelta(days=args.minage)).strftime("%Y-%m-%d")
|
||||||
],
|
],
|
||||||
"comparison": "<=>"
|
"comparison": "<=>"
|
||||||
|
},
|
||||||
|
"type":
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
"Asteroid base",
|
||||||
|
"Coriolis Starport",
|
||||||
|
"Mega ship",
|
||||||
|
"Ocellus Starport",
|
||||||
|
"Orbis Starport",
|
||||||
|
"Outpost",
|
||||||
|
"Planetary Outpost",
|
||||||
|
"Planetary Port",
|
||||||
|
"Settlement" if not args.nofeet else ""
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SORT = {
|
SORT = {
|
||||||
|
@ -187,11 +212,13 @@ try:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if args.system:
|
if args.system:
|
||||||
out = getOldStationsInSystem(args.system)
|
out = getOldStationsInSystem(args.system, args.raw)
|
||||||
else:
|
else:
|
||||||
out = getOldStations()
|
out = getOldStations(args.raw)
|
||||||
|
if args.raw:
|
||||||
|
out = JSON.dumps(out, indent=2)
|
||||||
elif args.subcommand == "systemexists":
|
elif args.subcommand == "systemexists":
|
||||||
out = systemExists(args.system)
|
out = systemExists(args.system, args.raw)
|
||||||
except ServerError as e:
|
except ServerError as e:
|
||||||
print(e)
|
print(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue