1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 08:17:13 +03:00

87 Commits

Author SHA1 Message Date
Athanasius
3c0ac76f90 Trace: Add support to EDMC.py & misc cleanups
* EDMC: Add --trace (to match EDMarketConnector.py) and TRACE as option to
  --loglevel.
* EDMC: docstrings added.
* EDMCLogging: Set logger name based on if GUI or CLI.
* EDMarketConnector:
  * Re-order imports.
  * Misc. formatting cleanups.
  * f-strings not .format().
  * Removed un-necessary "# noqa: N806" comments.
2020-09-23 17:38:38 +01:00
Athanasius
fa326ad3d3 EDMC.py: Move DEBUG logging to after level is set. 2020-09-22 15:54:18 +01:00
Athanasius
edc6ed6596 Add locale DEBUG logging to EDMC.py 2020-09-22 15:37:45 +01:00
Athanasius
f73a372e6b EDMC.py: Correct import eddn position, with isort comments
isort thinks this is a STDLIB import, when it's actually from the
plugins directory.  So add comments to stop isort from re-ordering it.
2020-09-11 14:09:47 +01:00
Athanasius
55fe4f37b8 EDMC: Blank line on scope change 2020-09-07 16:54:08 +01:00
Athanasius
30c9dbefc1 EDMC.py: General flake8 cleanup.
* Fix f-strings that are just plain strings.
* Sort imports.
* noqa E501 lines I want that long.
* And misc other minor cleanups.
2020-09-07 15:06:15 +01:00
Athanasius
faeb579be6 EDMC: Corrections to logging
* Use appcmdname as the logger name so it looks different from the GUI
  version.  This also causes a different log filename in the rotated log
  set.
* Log at DEBUG for Startup and Exiting.  Which means replacing all of
  the `sys.exit(EXIT_SUCCESS)` with `return` so we can log the Exit
  after `main()` returns and then `sys.exit(EXIT_SUCCESS)` there.
2020-09-07 14:10:27 +01:00
Athanasius
815b4695a6 Use logger.exception() to take care of showing the exception. 2020-09-06 19:19:23 +01:00
Athanasius
50c7220455 EDMC: Adding logging, including CL arg to set level 2020-09-06 19:07:37 +01:00
Athanasius
ed9a4cfe29 Revert "Cause EDMC.py to diff to check the detection"
This reverts commit 3b55a7a5deb009fac48b021602a074e3345afed2.
2020-07-29 15:00:39 +01:00
Athanasius
9a5884b57d Cause EDMC.py to diff to check the detection 2020-07-29 15:00:39 +01:00
A_D
f08d60d9b1 revert using json.dump
windows encodings dont like the weird characters
2020-07-26 23:08:47 +01:00
A_D
0e0c802b04 Fixed missed whitespace after scope changes 2020-07-26 23:08:47 +01:00
A_D
64b9cb39a9 Replaced file.write(json.dumps()) with json.dump
There's no reason to use json.dumps and directly encode it when we can
let the json lib do the heavy lifting
2020-07-26 23:08:47 +01:00
A_D
566f52e61f removed uneeded parens 2020-07-26 23:08:47 +01:00
A_D
14295ce9e8 Fixed scope whitespace and long lines 2020-07-26 23:08:47 +01:00
A_D
8b0f3e74cf Replaced format directives with fstrings 2020-07-26 23:08:47 +01:00
A_D
c6d8b4eab8 Renamed variable for clarity 2020-07-26 23:08:47 +01:00
A_D
0e000de90a Replaced type annotation with Optional
The return is Optional so the annotation on the other side must be as
well, lest we have large red squiggles
2020-07-26 23:08:47 +01:00
A_D
3dfca91e1d Fixed invalid deep_get call 2020-07-26 23:08:47 +01:00
A_D
b6482878f0 Fix deep_get not returning the correct on success
I forgot to actually return the given data if we manage to index to the
requested depth
2020-07-26 23:08:47 +01:00
A_D
2403ed1d2f Replaced missed .get chains with deep_get 2020-07-26 23:08:47 +01:00
A_D
4ee8869426 Revert part of e510b783
Apparently config.get does _not_ take a default param. It really should.
2020-07-26 23:08:47 +01:00
A_D
664605a315 Cleaned up ifs where possible
Removed redundant or unneeded parens, correctly added line breaks where
needed
2020-07-26 23:08:47 +01:00
A_D
1ed9225c44 Added main guard
Modules should _always_ check that they are main before doing any "real"
work
2020-07-26 23:08:47 +01:00
A_D
637f58bb06 Replaced modulo-formatting with .format 2020-07-26 23:08:47 +01:00
A_D
0dfad42de3 Replaced .get chains with a new method
`deep_get` will go down a list of keys on a dict to find either the
requested key or the default if somewhere along the line the given dict
doesn't have a given key
2020-07-26 23:08:47 +01:00
A_D
8117e18963 Don't recompile regexps where possible
While the python re lib _does_ cache compiled regexps, it only does this
to a point, it's better to compile once and hold a reference
2020-07-26 23:08:47 +01:00
A_D
37c01c028c Replaced list comprehension with generator
Creating a list here doesnt make sense when its almost instantly
recreated.
2020-07-26 23:08:47 +01:00
A_D
31c049deda Replace sys.stderr.write call with print
`print()` supports files other than stdout, and will automatically add
newlines for us, among other things
2020-07-26 23:08:47 +01:00
A_D
f9b860fd5c removed bare except clause 2020-07-26 23:08:47 +01:00
A_D
9d727aaa99 Remove unused variables in as e clauses 2020-07-26 23:08:47 +01:00
A_D
2592af8c9f block flake8 line length on doc line 2020-07-26 23:08:47 +01:00
A_D
2e21960568 add newlines on scope changes 2020-07-26 23:08:47 +01:00
A_D
1f1e34d722 ensure that comments have two spaces before
most of the files have tabs between code and comments
2020-07-26 23:08:47 +01:00
Athanasius
35f573bc14 Updater class now used for all updates checking
* Updater.__init__() now takes 'provider' argument to specify if we use
 the internal checking code, or the available external code.
* EDMC.py changed to utilise this with internal provider.
* EDMarketConnector.py changed to use internal provider if not frozen,
 else the internal provider.
* Corrected the darwin/MacOS toggling of auto updates checking to actually
 use the Sparkle, not WinSparkle, API call.
* Updater.check_appcast() does the internal checking:
    * class EDMCVersion to hold the information.
    * Returns None on any error, or if it didn't find a newer version.
    * Returns an EDMCVersion object if it found a newer version.
2020-07-19 11:45:07 +01:00
Athanasius
ea2c7f6894 Revert accidental change to test update_feed. 2020-07-19 11:45:07 +01:00
Athanasius
1ee8756983 Re-engineering of EDMC.py version update check
* Uses semantic_version.
* Filters on sparkle:os.
* Catches specific exceptions.
2020-07-19 11:45:07 +01:00
Athanasius
b1e1fc3a34 Restore 'EDMC -v' to announcing newer versions.
I got too enthusiastic in 3ff77c3c54dea4bf36d957cd2dbd5b1b02dcb094 when
I removed the "cut it down to A.BC" code.  This restores the old output,
but using a less confusing if/else.
2020-07-15 10:27:29 +01:00
A_D
be98365fb3
Fix #568 with ENV var workaround
EDMC.py would break due to an import chain that ends up in theme. Theme
does a whole bunch of work to setup our GUI for EDMarketConnector.py,
but it does this on any import, which will fail spectacularly if there
is either no DISPLAY var set or no X11 libs available on our machine at
all (as a sidenote this means it probably also breaks on a wholly
wayland install).

This fixes the issue by adding a check for an environment variable on
import of theme. This can and WILL break if the env var is set and
EDMarketConnector.py is used, but if you do that its your own fault.
2020-07-08 17:55:54 +02:00
Athanasius
3ff77c3c54 EDMC.py: import re, fix version compare and report
* I neglected to `import re` when I changed the Journal file name check.
* `map` isn't comparable in Python 3.7, need to `list()` it as well.
* Just print the full `appversion`.  The old code was assuming that none of
  A, B, C, D in A.B.C.D would be two or more digits.

close #566
2020-07-07 19:02:06 +01:00
Athanasius
942cbbfcfc Use a strict regex for matching Journal*.log files
A user accidentally copied a Journal file into the same directory, resulting in
a "Journal.<datetime>.<serial> - Copy.log" file.  EDMC 3.99.0.0 then picked this
up and re-sent events to EDDN, EDSM, Inara.

So, let's be strict about the filenames we consider to be valid, live, Journal
files.

 * Journal files have one basic form: Journal.YYMMDDHHMMSS.XX.log
 * In addition the word 'Beta' can be inserted just after 'Journal'

So regex '^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$' matches both and nothing
else.

Test: The "copy to same directory" that originally triggered this.  EDMC no
      longer 'sees' the copy.
Test: Copied a Journal file out, renamed it to later date/time, copied that
      back in.  EDMC saw it correctly as a new file.

NB: Didn't test the "no emitter" version at monitor.py:251, but no reason to
    think it won't also work.

closes #546
2020-07-02 17:54:04 +01:00
Jonathan Harris
92bbe7839b We don't need to explicitly set REQUESTS_CA_BUNDLE any more 2019-09-30 03:07:38 +01:00
Jonathan Harris
159bf95b77 All executable files invoked with #!/usr/bin/env python3 2019-09-30 02:50:52 +01:00
Athanasius
e51b4f5c68 Cleanup of EDMC.py and related code. All flags tested.
Mostly the usual file-mode versus .encode('utf-8') tweaks, but also
one list() needed around a <dict>.values().
2019-09-26 11:40:42 +01:00
Athanasius
f91baf8911 EDMC.py: Small fix to exception handling.
Now stymied on further work due to game patch today and CAPI being
down.
2019-09-26 11:40:42 +01:00
Athanasius
df987a3a40 Fixes up "EDMC.py -j" for python3 2019-09-26 11:40:42 +01:00
Athanasius
e9931aa348 Initial work on getting the EDMC.py CLI to work under python3
*) Fix up print usage
  *) cPickle -> cpickle
  *) "EDMC.py -p <cmdr name>" appears to have never been properly
  updated for multi-account support.
2019-09-26 11:40:42 +01:00
Athanasius
ac03fc583e Updates "EDMC.py -p <cmdr name>" for multi-account support. (#450) 2019-09-18 15:24:07 +01:00
Jonathan Harris
2a557fd37c Drop "keyring" requirement
Ref #418
2019-05-21 16:15:03 +02:00