Skip to content

Commit 2f00726

Browse files
committed
Ensure packaged version is handled for logging and auto-start
1 parent baece10 commit 2f00726

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

emailproxy.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__author__ = 'Simon Robinson'
77
__copyright__ = 'Copyright (c) 2023 Simon Robinson'
88
__license__ = 'Apache 2.0'
9-
__version__ = '2023-11-06' # ISO 8601 (YYYY-MM-DD)
9+
__version__ = '2023-11-10' # ISO 8601 (YYYY-MM-DD)
1010
__package_version__ = '.'.join([str(int(i)) for i in __version__.split('-')]) # for pyproject.toml usage only
1111

1212
import abc
@@ -240,8 +240,9 @@ def initialise(log_file=None):
240240
Log._LOGGER = logging.getLogger(APP_NAME)
241241
if log_file or sys.platform == 'win32':
242242
handler = logging.handlers.RotatingFileHandler(
243-
log_file or '%s/%s.log' % (os.path.dirname(sys.executable if getattr(sys, 'frozen', False) else
244-
os.path.realpath(__file__)), APP_SHORT_NAME),
243+
log_file or os.path.join(os.getcwd() if __package__ is not None else
244+
os.path.dirname(sys.executable if getattr(sys, 'frozen', False) else
245+
os.path.realpath(__file__)), '%s.log' % APP_SHORT_NAME),
245246
maxBytes=LOG_FILE_MAX_SIZE, backupCount=LOG_FILE_MAX_BACKUPS)
246247
handler.setFormatter(logging.Formatter('%(asctime)s: %(message)s'))
247248

@@ -2815,7 +2816,10 @@ def get_script_start_command(self, quote_args=True):
28152816

28162817
script_command = [python_command]
28172818
if not getattr(sys, 'frozen', False): # no need for the script path if using pyinstaller
2818-
script_command.append(os.path.realpath(__file__))
2819+
if __package__ is not None:
2820+
script_command.extend(['-m', APP_SHORT_NAME])
2821+
else:
2822+
script_command.append(os.path.realpath(__file__))
28192823

28202824
# preserve any arguments - note that some are configurable in the GUI, so sys.argv may not be their actual state
28212825
script_command.extend(arg for arg in sys.argv[1:] if arg not in ('--debug', '--external-auth'))

0 commit comments

Comments
 (0)