Python Forum
How to access variables from dirsync module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to access variables from dirsync module
#2
If you want to pass custom logger, you need to create logger object using logging module and pass it when call sync.
That is the way to customize reporting provided by the dirsync author.

As an alternative you can create your own sync function.
Look at dirsync.sync source code:
def sync(sourcedir, targetdir, action, **options):

    copier = Syncer(sourcedir, targetdir, action, **options)
    copier.do_work()

    # print report at the end
    copier.report()

    return set(copier._changed).union(copier._added).union(copier._deleted)
as you can see they instantiate dirsync.Syncer object. when the function execution completes this object is destroyed. That is why you don't have access to properties you want. You can do your own reporting (instead of calling copier.report()). Or you can make your function to return the statistics, instead of set of files affected as the original function does.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: How to access variables from dirsync module - by buran - Apr-02-2020, 04:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  importing variables from module 8376459 1 417 Feb-18-2024, 02:24 PM
Last Post: deanhystad
  Can't access the net using Python's Selenium module ShishirModi 2 2,190 Jul-21-2020, 06:03 AM
Last Post: ShishirModi
  module to store functions/variables and how to call them? mstichler 3 2,564 Jun-03-2020, 06:49 PM
Last Post: mstichler
  help with threading module and passing global variables ricardons 1 8,087 Feb-21-2019, 12:48 PM
Last Post: stullis
  How can classes access each other Functions and Variables at the same time PythonOK 4 3,206 Dec-09-2018, 03:46 AM
Last Post: ichabod801
  f2py recovering variables from Fortran module marius 0 3,557 Dec-02-2016, 03:52 PM
Last Post: marius

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020