Apr-02-2020, 04:20 AM
(This post was last modified: Apr-02-2020, 04:21 AM by steve_shambles.)
I have just completed a new project called Sync It,
it uses the excellent dirsync module.
I achieved all that I wanted to in my little app except
for one glaring omission and that was to report the file
statistics after a sync operation.
The sync module does a good job of this and the report is
sent to the Python shell, but because I am running from an
executable and from the system tray I can't seem to access
these variables.
I thought it would just be a case of module_name.variable,
for example:
dirsync._numdelfiles
but that doesn't work.
An alternative solution might be mentioned in the docs of dirsync
quote:
"Custom logger
From python, you may not want to have the output sent to stdout.
To do so, you can simply pass your custom logger via the
logger keyword argument of the sync function:
sync(sourcedir, targetdir, action, logger=my_logger, **options)"
unquote.
When I put logger=my_logger in my sync line I just get a
NameError: name 'my_logger' is not defined error.
I know nothing of logging yet either (obviously) so I'm
off to do some reading in case nobody can save me time
and a headache here with the solution.
My Sync It code is on Github if you want it.
cheers.
it uses the excellent dirsync module.
I achieved all that I wanted to in my little app except
for one glaring omission and that was to report the file
statistics after a sync operation.
The sync module does a good job of this and the report is
sent to the Python shell, but because I am running from an
executable and from the system tray I can't seem to access
these variables.
I thought it would just be a case of module_name.variable,
for example:
dirsync._numdelfiles
but that doesn't work.
An alternative solution might be mentioned in the docs of dirsync
quote:
"Custom logger
From python, you may not want to have the output sent to stdout.
To do so, you can simply pass your custom logger via the
logger keyword argument of the sync function:
sync(sourcedir, targetdir, action, logger=my_logger, **options)"
unquote.
When I put logger=my_logger in my sync line I just get a
NameError: name 'my_logger' is not defined error.
I know nothing of logging yet either (obviously) so I'm
off to do some reading in case nobody can save me time
and a headache here with the solution.
My Sync It code is on Github if you want it.
cheers.