1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-18 09:57:40 +03:00

328 Commits

Author SHA1 Message Date
Athanasius
09add21a1a Logging: DEBUG always to rotated files, configured level to stdout/err
* EDMCLogging.Logger.get_streamhandler() method to get the
  logger_channel so prefs.py can call setLevel() on it.
* The top-level Logger level is always DEBUG.
* The RotatingFileHandler level is always DEBUG.
* The StreamHandler level is as configured by the user.
* EDMCLogging now creates a singleton of EDMCLogging.Logger and its
  associated Logger.
* plug.py tweaked to only import EDMCLogging where it's needed for
  getting/creating plugin loggers, else `import logging`.
2020-09-08 10:03:16 +01:00
Athanasius
d940357854 EDMarketConnector.py: Blank line at the end. 2020-09-07 14:44:09 +01:00
Athanasius
10c3fec4f8 Logging: Set configured loglevel on creation 2020-09-07 14:40:55 +01:00
Athanasius
c3fbd1164e Logging: Implement additional logging to rotated set of files.
* All logging duplicated into %TEMP%/{appname}/{logger_name}.log
* These are handled by the RotatingFileHandler, currently set to 1MiB
  per file and 10 backup files.
* Do *NOT* setLevel() on the handlers, as we want to control the level
  up at the logger instead.  This would have caused the CL and GUI
  selection of loglevel to NOT have any effect (hidden by default having
  been DEBUG).
* EDMarketConnector.py now INFO logs its startup and exit.
2020-09-07 14:17:49 +01:00
Athanasius
bebe162071 logging: Now setting loglevel from Settings, and loading at start 2020-09-06 18:29:26 +01:00
Athanasius
c126251246 "Not Python 3.x" popup message sub-substitutions fixed.
string.format() doesn't assign to string, so actually need to do that.
2020-08-27 11:30:13 +01:00
Athanasius
98b6d4db38 Plugins "Not Python 3.x": Hacky escaping fix so translations work 2020-08-27 11:30:05 +01:00
Athanasius
3b87df17af Tweak EDMarketConnector.py startup so the redirect is first
* Don't want any output until the redirect is done when running frozen.
* Make the line buffering in the redirect more obvious.
2020-07-29 15:02:47 +01:00
Athanasius
4ecb4f573a 2 lines after def test_logging() 2020-07-29 15:02:47 +01:00
Athanasius
589bc0b5f1 Cover all cases with inspect
* <module> works.
* top-level function in <module> works, presumably also any other file.
* Call from within classes works.
* Extra, commented out, test cases in EDMarketConnector.py
2020-07-29 15:02:47 +01:00
Athanasius
a5b7bea2ca Move comment to line above if 2020-07-27 15:16:23 +01:00
Athanasius
9face638fe Minor cleanups all done.
Only remaining are:

 * TAE001 too few type annotations
 * Multiple "Cognitive complexity is too high" / "is too complex"
2020-07-27 13:00:59 +01:00
Athanasius
e0324cb9cd More flake8 cleanup 2020-07-27 11:15:03 +01:00
Athanasius
63f3859af4 Remove extraneous __class__ in logging strings 2020-07-27 10:56:57 +01:00
Athanasius
19e750eddd Use logger.exception() not log.error(.., exc_info=..) 2020-07-27 10:47:57 +01:00
Athanasius
6c9139e395 TODO: unittest hint about testing logging
And comment out the use of it here.
2020-07-27 10:35:08 +01:00
Athanasius
d7c2372417 Flake8 cleanup round #2 2020-07-27 10:14:16 +01:00
Athanasius
f9a23cc831 Clean up flake8 output for this branch 2020-07-27 09:37:10 +01:00
Athanasius
307910739a Remove now un-necessary imports for logging/traceback 2020-07-27 06:57:53 +01:00
Athanasius
66e2c354c7 Documentation update and getLogger() -> get_logger()
* Technically %(class)s can be e.g. A.B not just 'B' so say "name(s)".
* To not confuse EDMCLogging.getLogger() with logging.getLogger() it's
 been renamed to get_logger().
* Note how we signal errors with finding class and/or qualname.
* Call out EDMCLogging.py in Contributing.md.
2020-07-27 06:57:53 +01:00
Athanasius
596527bda2 Move logging setup to EDMCLogging.py with a class
* Also now providers single caller_class_and_qualname() method to get
 both strings, returned as a Tuple[str, str].  Either could be empty
 if something went wrong.
* Rather than a fragile 'skip' this now:
    1. Looks for the first up-stack frame with self of logging.Logger
    1. Then looks for the next up-stack frame with self NOT of
     logging.Logger.  This should be the call site we want.
2020-07-27 06:57:53 +01:00
Athanasius
c196a38e09 Add logging TODOs. logger creation & frame detection
* Nothing should "from EDMarketConnector import logger" any more, so
 we can move this back inside __main__ section
* We shouldn't rely on a magic number of frames to skip.  Detect the
 proper frame automatically.
2020-07-27 06:57:52 +01:00
Athanasius
2176187be7 Fix typos in class/qualname finders 2020-07-27 06:57:52 +01:00
Athanasius
4d7f81cec1 Add emergency print()s if we can't find class/qualname 2020-07-27 06:57:52 +01:00
Athanasius
89cadbc0eb Add paranoia checks to class and qualname finders 2020-07-27 06:57:52 +01:00
Athanasius
5af87a5b98 Clean up EDMarketConnector.py after that qualname testing 2020-07-27 06:57:52 +01:00
Athanasius
6b9d4a11cb Use a logging.Filter to implement %(qualname)s in formatting.
This gets the function that called the logging, and if it's in a class
it looks up the function via getattr(<class>, <func name>) and then
uses __qualname__ to quickly get the fully qualified name.
2020-07-27 06:57:52 +01:00
Athanasius
debc7f97d3 Use a logging.Filter to implement %(class)s in formatting. 2020-07-27 06:57:52 +01:00
Athanasius
23b167fe66 Change startup version back to a print()
This is so early it doesn't need to be a spammy log message.
2020-07-27 06:57:27 +01:00
Athanasius
fe0ff2498e Moves logger definition so it's import'able 2020-07-27 06:57:23 +01:00
Athanasius
c971106c0e Convert print()s to logging & refactor help_about -> HelpAbout 2020-07-27 06:57:23 +01:00
Athanasius
cd4216d19c logger setup and initialisation
* Initial printing of version is now a logger.info(...)
2020-07-26 23:16:52 +01:00
Athanasius
e1752506c5 Move "only run once" code into def enforce_single_instance() 2020-07-26 23:16:52 +01:00
A_D
99014dd970 Added a config to use the new file based shipyard
This also reverts commenting out the old solution for long URLs
2020-07-23 14:36:02 +01:00
A_D
b818922193 Fixed issues with super long links for shipyards
This works by creating a temp file at config.app_dir and storing the
link in there, followed by directing the local browser to open the file.

HTML meta tags are then used to direct the browser to refresh to a URL
of our choosing (which is HTML escaped, just in case someone tries
something clever)

This should work everywhere, and on any browser (as the file:// format
is defined at https://tools.ietf.org/html/rfc1738 which was posted in
1994).

The URI used (`file://localhost/path`) ensures that we only ever
ask for a localhost file at our path.

The HTML format should be completely compliant with all major browsers
as well, ensuring that behaviour is consistent (assuming they support
HTML meta tags)
2020-07-23 14:36:02 +01:00
Athanasius
4435bb004a Technically could still be frozen with darwin and thus non-Win Sparkle 2020-07-19 11:45:07 +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
cba673ae12 Correct 'compoun' to 'compound' in 'Release Notes' URL code 2020-07-19 11:45:07 +01:00
Athanasius
66a63597f1 Use appversion_nobuild in 'Release Notes' URL 2020-07-19 11:45:06 +01:00
Athanasius
c1221fb6fc Change 'Release Notes' URL to use 'Release/A.B.C.D' tag form
Closes #544
2020-07-01 17:11:23 +01:00
Athanasius
38593058f4 Use translations of some words in Python 3.x popup text
'File', 'Settings' and 'Plugins' are defined to have translations for
the menus/tabs texts, so use them.
2020-07-01 15:55:37 +01:00
Athanasius
821111284e Add translations for python 3.x warning popup 2020-07-01 15:55:37 +01:00
Athanasius
314fc7082d Implements 'Help > About' menu item
* Re-uses the 'About {APP}' that was defined because the MacOS version
   always had an 'About' bit.
 * As a side effect of wanting the copyright string in the popup this is
   now defined in config.py, and setup.py has been adjusted to also take
   it from there.
 * The About popup includes a link to the release notes, contingent on
   the git tag existing on github.
 * Only one instance of the popup is allowed at once.
 * There's still a 'TODO' for moving 'Check for updates' into this
   popup.

Addresses issue #509
2020-07-01 15:44:20 +01:00
Bernd Gollesch
77a2a1b533 Use the after method of root to open the messagebox inside the mainloop (fixes #522). 2020-06-21 22:05:12 +02:00
Athanasius
b829c1bbd1 Remove the 'plugins not py 3.x' warning popup from EDMarketConnector.py
This *was* moved to plug.py, and it executing there prevents this
version from actually causing a popup, but it doesn't belong here.
2020-06-21 20:15:33 +01:00
Athanasius
558392d21b Move "plugins need migrating" popup to plug.py
Where it was in EDMarketConnector.py caused issues because then the
main thread was blocking on the popup when other threads expected it to
be running:

---------------------------------------------------------------------
Exception in thread Journal worker:
Traceback (most recent call last):
  File "C:\Users\Athan\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\Athan\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Athan\Documents\Devel\EDMarketConnector-python3\monitor.py", line 273, in worker
    self.root.event_generate('<<JournalEvent>>', when="tail")
  File "C:\Users\Athan\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1673, in event_generate
    self.tk.call(args)
RuntimeError: main thread is not in main loop
---------------------------------------------------------------------

However *now* it pops up before the main UI is running properly at all,
so the EDMC window is likely out of position, and won't be
painted/themed yet.
  This is deemed acceptable for a 'once a day at most' popup.

  The popup title now has 'EDMC: ' at the start to be sure users know
what it's talking about.
  It also has some brief advice about how to disable a plugin.
2020-06-21 17:14:16 +01:00
Athanasius
8690f1bb83 Fix old style 'print ' statements 2020-06-21 16:58:21 +01:00
Athanasius
a40b0e33ca Detect plugins without Python 3.x support and warn user.
To allow users to sort out their plugins before EDMC itself moves to
Python 3.x warn them if any of their enabled, non-stock, plugins do not
have a plugin_start3() method.

  * If any are found without support there's a popup triggered at the
    end of AppWindow initialisation.
  * Then the user can check Settings > Plugins to see a list of the
    plugins without Python 3.x support.
2020-06-21 16:57:37 +01:00
Athanasius
259bb3bbd6 Merge branch 'release-final-python27' into python3 2020-06-21 16:43:02 +01:00
Jonathan Harris
3fe4454888 Fix for DDE registration 2020-06-21 16:32:09 +01:00