1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-24 04:30:54 +03:00

5299 Commits

Author SHA1 Message Date
Athanasius
e5862da7eb
startup/one-process: Remove temporary debug logging
This was to be sure *that* bit of code was being hit and working without
issues.  It is.
2023-01-13 16:52:31 +00:00
Athanasius
f7ce051d88
startup/one-process: Use pythoncom COINIT_ constants 2023-01-13 16:51:44 +00:00
Athanasius
caa06475e0
Startup/one-process: All the ctypes gone in favour of pywin32
I currently can't find where pywin32 defines COINIT_APARTMENTTHREADED and
COINIT_DISABLE_OLE1DDE so am still having to hard-define those.
2023-01-13 15:15:09 +00:00
Athanasius
f4ac9907a3
monitor/EnumWindows: Handle possible false-positive exception
Somehow I didn't run into this with testing *this* invocation of
`win32gui.EnumWindows()`, but then I did over in EDMarketConnector.py.  So,
as I had to handle the exception there, let's also do it here.
2023-01-13 15:13:43 +00:00
Athanasius
56f82668c6
startup/one-process: Replace EnumWindows & GetClassName with pywin32
At this time this errors, but that might be due to mixing ctypes and
pywin32 code.
2023-01-13 14:26:57 +00:00
Athanasius
30239a4916
startup/one-process: Convert window_title() to pywin32 2023-01-13 14:18:21 +00:00
Athanasius
85ed69463c
monitor: Don't synthesize StartUp if current event is ShutDown 2023-01-13 14:04:01 +00:00
Athanasius
bb258aeb0a
monitor: Check if found 'ed process' is running as current user
This is something the old code *didn't actually do*.

Tested with a 'pseudo ed' process (same MainWindowTitle) running as myself
(test matches), and via `runas` as another user (doesn't match).
2023-01-13 12:29:56 +00:00
Athanasius
95b52bff01
monitor: Comment about 'as this User' not actually being true
Both the current `develop` code and this PR's new code share this behaviour.
What the code does is look for windows/processes *in the current Windows
session*, no matter if they're owned by the session user or not.

Neither version will find a process, that would match, if it's running in
another session, i.e. you'd need to switch to it via the windows Login screen.
2023-01-13 11:07:15 +00:00
Athanasius
4f017a77e8
monitor: Change last ctypes code to pywin32 instead
* All of the implementation of the EnumWindows callback.

The documentation for pywin32 isn't great, in terms of finding the call
convention and necessary form of parameters, but once you do this is *much*
cleaner than using ctypes directly.

I'm not 100% certain that `win32api.OpenProcess()` has the same semantic as
the previous `GetProcessHandleFromHwnd()`, i.e. only getting the `handle`
back if the process is owned by the current user.  If the user has
Windows Administrator rights they can probably kill other users' processes ?
2023-01-12 18:31:45 +00:00
Athanasius
b24e998931
monitor: Replace EnumWindows() with pywin32 version 2023-01-12 17:50:52 +00:00
Athanasius
2c469441e0
monitor: Just use the pywin32 win32gui.GetWindowText(), it works
After over an hour's struggle trying to get the win32/user32
`GetWindowTextW()` prototyped properly, and running into problem after problem:

    1. Once you properly prototype this, including defining the 2nd `lpString`
      parameter as 'out', ctypes wants to just *return* that.
    2. This leads to then implementing a `.errcheck` property so that you
      can *also* check the INT result for errors.
    3. But then you just run into another error.

I finally found <https://stackoverflow.com/a/10905155> which pointed out
you can simply use `win32gui.GetWindowText()` from `pywin32`.  Tested, it
simply works, no errors/exceptions.
2023-01-12 17:35:01 +00:00
Athanasius
d5a1fc4001
monitor: Prototype GetWindowTextW & GetWindowTextLengthW 2023-01-12 16:23:32 +00:00
Athanasius
0a8d383310
monitor: Prototype CloseHandle 2023-01-12 16:13:00 +00:00
Athanasius
aaf83645f7
monitor: Properly prototype EnumWindows 2023-01-12 16:04:44 +00:00
Athanasius
e5709727b6
monitor: Rename GetWindowTextLength to GetWindowTextLengthW
It's using the win32/user32 GetWindowTextLengthW() so name it appropriately.
2023-01-12 15:52:49 +00:00
Athanasius
085159f8cb
When it's a StartUp event say *that*, not Startup
This check in EDMarketConnector.py is explicitly for StartUp (and Loadgame),
not Startup, so have the logging say that.
2023-01-12 15:03:43 +00:00
Athanasius
3d41be7651
monitor: log INFO when for-plugins StartUp event synthesized
This is actually to do with a reported issue around the ctypes code in
`EDLogs.gamerunning()` causing:

```python
exception ignored on calling ctypes callback function: <function EDLogs.game_running.<locals>.callback at 0x0000020E9C9D0EA0>
Traceback (most recent call last):
  File "monitor.pyc", line 2041, in callback
  File "monitor.pyc", line 2034, in WindowTitle
ctypes.ArgumentError: argument 1: OverflowError: int too long to convert
```

Although I can't personally get this to trigger at all under 64-bit python,
either in PyCharm *or* with the 5.7.1-alpha1 64-bit pre-release.

`game_running()` is only used in a few places, and the key things it
malfunctioning might cause are lack of the synthetic `ShutDown` (already
has an INFO logging) and `StartUp` events.
2023-01-12 14:50:44 +00:00
Athanasius
c350782a67
Merge pull request #1802 from EDCD/enhancement/1801/custom-release-archives
Create a custom .zip archive for releases
2023-01-12 14:05:14 +00:00
Athanasius
48a80411b4
windows-build/tar: Make archive at .. and then mv into 'root'
* Because the archive is a new file in the root it causes:

    `tar: EDMarketConnector: file changed as we read it`

  Verified on Linux/Debian, and also verified that this fix works.
2023-01-12 13:47:41 +00:00
Athanasius
2678d7d63f
windows-build/tar: New job needs to depend on variables 2023-01-12 13:10:43 +00:00
Athanasius
bcfcc8c71c
windows-build/tar: tar needs to be in job *after* variables
At least we had `-f EDMarketConnector-release-.tar.gz ` which implies the
`needs.variables.outputs.sem_ver` variable wasn't yet set.
2023-01-12 13:06:53 +00:00
Athanasius
a00c6f789a
windows-build/tar: Adjust argument ordering
`-C ..` applies to anything that happens after it, so needs to be after the
`-f <file>`.
2023-01-12 13:03:06 +00:00
Athanasius
d52f161dc9
windows-build/tar: run, not script. 2023-01-12 12:58:10 +00:00
Athanasius
048be66f54
windows-build/tar: Just run a tar command ourselves directly
thedoctor0/zip-release has a bug where only the first word in `exclusions`
has `--exclude=` pre-pended to it, the other words being treated as input
filenames/globs/paths.  So, let's do this manually.
2023-01-12 12:54:19 +00:00
Athanasius
042c8d4ff2
windows-build/tar: Move to running under ubuntu
* On windows specifying only filenames to exclusions causes things like
  `tar: .editorconfig: Cannot stat: No such file or directory`

  But putting `EDMarketConnector/` prefix on such means they don't work.

* Testing with 'git bash' GNU tar 1.34:

  `tar -c -v -z -f edmc-test.tar.gz --exclude=.editorconfig --exclude=.git\* EDMarketConnector`

  works, with empty output from:

  `tar tfvz edmc-test.tar.gz | grep editorconfig`
2023-01-12 12:34:44 +00:00
Athanasius
3e05f91949
windows-build/tar: Now we have directory we *do* need exclusion paths
* Maybe I was wrong about not needing the prefix path on tar exclusions,
  because that was when I'd not copied `directory`.
2023-01-12 12:18:09 +00:00
Athanasius
15ee894142
windows-build/archives: Re-order to very early, add directory to tar
* I'd missed copying the `directory` line from zip to tar step.
* There's no reason we can't perform these steps *before* the build, or
  even the python setup, so move them up there.  That has the near side-effect
  of not needing to exclude so much stuff.
2023-01-12 12:14:00 +00:00
Athanasius
7098479902
windows-build/tar: Different specification of exclusions 2023-01-12 12:03:51 +00:00
Athanasius
43d10ab29a
windows-build/archives: Can't multiple setOutput, use env instead
* As the archive exclusions is static, we can just set it in workflow env.
2023-01-12 11:53:17 +00:00
Athanasius
4edebf981f
windows-build/archives: Create .tar.gz as well
* Move the definition of archive excludes to a global variable.
* Add another step to create a tar(.gz) archive as well.
* Add .tar.gz to the `Built files` handling.
2023-01-12 11:39:35 +00:00
Athanasius
1c1329ca17
Merge pull request #1803 from EDCD/dependabot/pip/develop/coverage-toml--7.0.5
build(deps-dev): bump coverage[toml] from 7.0.4 to 7.0.5
2023-01-11 18:11:06 +00:00
Athanasius
64b1a4afd6
windows-build/custom zip: Add comment about the "too long args" issue 2023-01-11 18:10:18 +00:00
Athanasius
a37be45343
Merge pull request #1800 from EDCD/enhancement/1041/desktop-file
.desktop: Add a file, and adjust icon filename to suit
2023-01-11 18:09:55 +00:00
dependabot[bot]
5713a2e11c
build(deps-dev): bump coverage[toml] from 7.0.4 to 7.0.5
Bumps [coverage[toml]](https://github.com/nedbat/coveragepy) from 7.0.4 to 7.0.5.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](https://github.com/nedbat/coveragepy/compare/7.0.4...7.0.5)

---
updated-dependencies:
- dependency-name: coverage[toml]
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-11 17:01:28 +00:00
Athanasius
804b450c82
windows-build: Custom zip: Reduce exclusions
It *seems* we don't need to specify both a directory and its contents.

Also, hopefully this will fix the:

    Creating zip archive...

    Command Line Error:
    Unknown switch:
    -

which the last run got.  That was where the 'root' directory prefix was
added to all exclusions.  Maybe the commandline got too long ?
Release/5.7.1-alpha0+test8
2023-01-11 13:19:04 +00:00
Athanasius
0c0c14166d
windows-build: custom zip exclusions need 'root' prefix
Also, comment out exactly what we're doing in the zip-release configuration,
and why.
2023-01-11 12:58:05 +00:00
Athanasius
531c839d13
windows-build: Specify custom zip to be in the 'root' directory
zip-release does indeed create this in `directory`, so we need to specify
it should be *in* the 'root' directory that we're including *in* the zip file.
2023-01-11 12:46:28 +00:00
Athanasius
2531e6de23
windows-build: Can't use relative path for upload-artifact
So, let's *hope* that zip-release still puts the .zip it creates in the
main directory, despite being told to create it from the parent.
2023-01-11 12:38:08 +00:00
Athanasius
35b5a90409
windows-build: Custom zip: Include top-level directory, and exclude more 2023-01-11 12:27:17 +00:00
Athanasius
c48cfeca5d
windows-build: Fix 'needs' reference to windows_build job 2023-01-11 12:12:30 +00:00
Athanasius
c8e6285a13
windows-build: Create a custom release .zip 2023-01-11 12:05:53 +00:00
Athanasius
a67609696c
windows-build: Properly name the build job 2023-01-11 11:36:54 +00:00
Athanasius
bc610f618d
sub-modules: Change coriolis-data to an https URL, not git@
Someone cloning shouldn't *need* a github account in order to get the
sub-modules.
2023-01-11 11:24:30 +00:00
Athanasius
5473c62104
Merge pull request #1799 from EDCD/dependabot/pip/develop/coverage-toml--7.0.4
build(deps-dev): bump coverage[toml] from 7.0.3 to 7.0.4
2023-01-10 15:48:01 +00:00
Athanasius
b630445315
Linux: Add install/setup and startup script
This *should* allow for easy setup to work on any XDG-compliant desktop
environment.  Just run `scripts/linux-setup.sh` and it will:

1. Determine the 'root' directory of the EDMarketConnector source you're
  using.
2. Check you have `${HOME}/bin` in PATH and it exists as a directory.
3. Copy `scripts/edmarketconnector.sh` to there, replacing the string
  `EDMC_PATH` with the 'root' directory.
4. Copy .png (icon) and .desktop files into ~/.local/share/... locations.

Then the desktop environment should have a menu entry for
"E:D Market Connector", which attempts to run `edmarketconnector`, which
should now be the shell script present in ${HOME}/bin.
2023-01-10 14:59:54 +00:00
Athanasius
6b38de1080
.desktop: Add a file, and adjust icon filename to suit
1. `io.edcd.EDMarketConnector.desktop` based on the flathub one, but with
  reference to v1.5 of the spec (linked in a file comment).
2. As the Icon is specified using `io.edcd.EDMarketConnector`, not only
  `EDMarketConnector`, renamed the .png file and updated the single code
  reference to it.
2023-01-10 14:04:41 +00:00
Athanasius
596df0f987
CAPI 'Save Raw Data': Add '.' between system and station names in filename
It's apparently *always* just mushed them together, but that's really crap.
2023-01-10 11:49:58 +00:00
dependabot[bot]
881d689331
build(deps-dev): bump coverage[toml] from 7.0.3 to 7.0.4
Bumps [coverage[toml]](https://github.com/nedbat/coveragepy) from 7.0.3 to 7.0.4.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](https://github.com/nedbat/coveragepy/compare/7.0.3...7.0.4)

---
updated-dependencies:
- dependency-name: coverage[toml]
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-09 17:01:28 +00:00
Athanasius
f8a2e6916d
Merge pull request #1796 from EDCD/dependabot/pip/develop/coverage-toml--7.0.3
build(deps-dev): bump coverage[toml] from 7.0.2 to 7.0.3
2023-01-04 17:03:22 +00:00