Example #1
0
 def __init__(self, parent, *args, **kw):
     self.variable = kw.pop("variable", Tkinter.IntVar(0))
     self.value = kw.pop("value", 0)
     utilities.setDefault(kw, bindunclick = False, mousedown = self.select)
     Button.__init__(self, parent, *args, **kw)
     self._callback()
     self.variable.trace("w", self._callback)
Example #2
0
 def __init__(self, parent, *args, **kw):
     utilities.setDefault(kw, border = 0, highlightthickness = 1, bg = bg, highlightbackground = "black",
                 height = 15)
     Tkinter.Canvas.__init__(self, parent, *args, **kw)
     self.progressbar = self.create_rectangle(0, 0, 0, 0, fill = lightbg)
     self.currprogress = 0
     self.setProgress(0)
Example #3
0
 def __init__(self, parent, *args, **kw):
     utilities.setDefault(kw,
                          highlightthickness=0,
                          borderwidth=0,
                          background=bg,
                          relief=Tkinter.FLAT)
     Tkinter.Frame.__init__(self, parent, *args, **kw)
Example #4
0
def sizeTrans(size, htom=True):
    utilities.setDefault(size, T=0, G=0, M=0, K=0, B=0)
    KB = 1024
    MB = 1048576
    GB = 1073741824
    TB = 1099511627776
    addme = 0
    if size["T"] > 0:
        addme = addme + size["T"] * TB
    if size["G"] > 0:
        addme = addme + size["G"] * GB
    if size["M"] > 0:
        addme = addme + size["M"] * MB
    if size["K"] > 0:
        addme = addme + size["K"] * KB
    if size["B"] > 0:
        addme = addme + size["B"]
    if htom:
        return addme
    else:
        if htom == "T":
            return addme / TB
        if htom == "G":
            return addme / GB
        if htom == "M":
            return addme / MB
        if htom == "K":
            return addme / KB
        if htom == "B":
            return addme
Example #5
0
    def __init__(self, parent, *args, **kw):
        utilities.setDefault(kw, background = bg, borderwidth = 0, highlightthickness = 0, relief = Tkinter.FLAT)
        Frame.__init__(self, parent, *args, **kw)
        def showFunc():
            self.vscrollbar.pack(fill = Tkinter.Y, side = Tkinter.RIGHT, expand = Tkinter.FALSE)
        def hideFunc():
            self.vscrollbar.pack_forget()
        self.vscrollbar = GScrollbar(self, orient = Tkinter.VERTICAL)
        self.vscrollbar.pack(fill = Tkinter.Y, side = Tkinter.RIGHT, expand = Tkinter.FALSE)
        self.canvas = Tkinter.Canvas(self, kw, yscrollcommand = self.vscrollbar.set)
        self.canvas.pack(side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = Tkinter.TRUE)
        self.vscrollbar.config(command = self.canvas.yview)
        self.canvas.xview_moveto(0)
        self.canvas.yview_moveto(0)
        self.interior = interior = Frame(self.canvas, kw)
        interior.pack(fill = Tkinter.BOTH, expand = Tkinter.TRUE)
        interior_id = self.canvas.create_window(0, 0, window = interior,
                                           anchor = Tkinter.NW)

        def _configure_interior(event):
            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
            self.canvas.config(scrollregion = "0 0 %s %s" % size)
            if interior.winfo_reqwidth() != self.canvas.winfo_width():
                self.canvas.config(width = interior.winfo_reqwidth())
        interior.bind('<Configure>', _configure_interior)

        def _configure_canvas(event):
            if interior.winfo_reqwidth() != self.canvas.winfo_width():
                self.canvas.itemconfigure(interior_id, width = self.canvas.winfo_width())
        self.canvas.bind('<Configure>', _configure_canvas)
Example #6
0
 def __init__(self, parent, *args, **kw):
     self.command = kw.pop("command", None)
     bindclick = kw.pop("bindclick", True)
     bindunclick = kw.pop("bindunclick", True)
     self.mousedown = kw.pop("mousedown", None)
     utilities.setDefault(
         kw,
         background=bg,
         foreground=fg,
         borderwidth=0,
         pady=3,
         padx=8,
         highlightbackground=_rgbtohex(normalc),
         highlightthickness=1,
     )
     Tkinter.Label.__init__(self, parent, *args, **kw)
     self.lastcolor = normalc
     self.renderthread = None
     self.hovering = False
     self.clicking = False
     self.bind("<Enter>", self.hoveringtrue)
     self.bind("<Leave>", self.hoveringfalse)
     if bindclick:
         self.bind("<ButtonPress-1>", self.onclick)
     if bindunclick:
         self.bind("<ButtonRelease-1>", self.onunclick)
Example #7
0
def sizeTrans(size, htom=True):
    utilities.setDefault(size, T=0, G=0, M=0, K=0, B=0)
    KB = 1024
    MB = 1048576
    GB = 1073741824
    TB = 1099511627776
    addme = 0
    if size["T"] > 0:
        addme = addme + size["T"] * TB
    if size["G"] > 0:
        addme = addme + size["G"] * GB
    if size["M"] > 0:
        addme = addme + size["M"] * MB
    if size["K"] > 0:
        addme = addme + size["K"] * KB
    if size["B"] > 0:
        addme = addme + size["B"]
    if htom:
        return addme
    else:
        if htom == "T":
            return addme / TB
        if htom == "G":
            return addme / GB
        if htom == "M":
            return addme / MB
        if htom == "K":
            return addme / KB
        if htom == "B":
            return addme
Example #8
0
 def __init__(self, parent, *args, **kw):
     self.variable = kw.pop("variable", Tkinter.IntVar(0))
     self.value = kw.pop("value", 0)
     utilities.setDefault(kw, bindunclick=False, mousedown=self.select)
     Button.__init__(self, parent, *args, **kw)
     self._callback()
     self.variable.trace("w", self._callback)
Example #9
0
 def __init__(self, parent, *args, **kw):
     self.value = Tkinter.IntVar()
     utilities.setDefault(
         kw, background=bg, borderwidth=0, highlightthickness=0, foreground=fg,
         selectcolor=bg, activebackground=bg, activeforeground=fg,
         variable=self.value)
     Tkinter.Checkbutton.__init__(self, parent, *args, **kw)
Example #10
0
    def __init__(self, parent, *args, **kw):
        utilities.setDefault(kw, background=bg, borderwidth=0, highlightthickness=0, relief=Tkinter.FLAT)
        Frame.__init__(self, parent, *args, **kw)

        def showFunc():
            self.vscrollbar.pack(fill=Tkinter.Y, side=Tkinter.RIGHT, expand=Tkinter.FALSE)

        def hideFunc():
            self.vscrollbar.pack_forget()

        self.vscrollbar = GScrollbar(self, orient=Tkinter.VERTICAL)
        self.vscrollbar.pack(fill=Tkinter.Y, side=Tkinter.RIGHT, expand=Tkinter.FALSE)
        self.canvas = Tkinter.Canvas(self, kw, yscrollcommand=self.vscrollbar.set)
        self.canvas.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=Tkinter.TRUE)
        self.vscrollbar.config(command=self.canvas.yview)
        self.canvas.xview_moveto(0)
        self.canvas.yview_moveto(0)
        self.interior = interior = Frame(self.canvas, kw)
        interior.pack(fill=Tkinter.BOTH, expand=Tkinter.TRUE)
        interior_id = self.canvas.create_window(0, 0, window=interior, anchor=Tkinter.NW)

        def _configure_interior(event):
            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
            self.canvas.config(scrollregion="0 0 %s %s" % size)
            if interior.winfo_reqwidth() != self.canvas.winfo_width():
                self.canvas.config(width=interior.winfo_reqwidth())

        interior.bind("<Configure>", _configure_interior)

        def _configure_canvas(event):
            if interior.winfo_reqwidth() != self.canvas.winfo_width():
                self.canvas.itemconfigure(interior_id, width=self.canvas.winfo_width())

        self.canvas.bind("<Configure>", _configure_canvas)
Example #11
0
 def __init__(self, parent, *args, **kw):
     utilities.setDefault(kw,
                          background=bg,
                          foreground=fg,
                          borderwidth=0,
                          pady=6,
                          padx=6,
                          highlightbackground=_rgbtohex(normalc),
                          highlightcolor=_rgbtohex(hoverc))
     Tkinter.Label.__init__(self, parent, *args, **kw)
Example #12
0
 def __init__(self, parent, *args, **kw):
     utilities.setDefault(kw, background = lightbg, borderwidth = 0, relief = Tkinter.FLAT,
                 activebackground = lightbghover, troughcolor = bg)
     if kw.get("showfunc"):
         self.showfunc = kw.pop("showfunc")
     if kw.get("hidefunc"):
         self.hidefunc = kw.pop("hidefunc")
     Tkinter.Scrollbar.__init__(self, parent, *args, **kw)
     self.bind("<ButtonPress-1>", self.onclick)
     self.bind("<ButtonRelease-1>", self.onunclick)
Example #13
0
def adrm(dirs, **options):
    utilities.setDefault(options,
                         excludes=[],
                         remdirs=True,
                         remsymlink=True,
                         remfullpath=False,
                         remoriginal=True,
                         tn="",
                         progressfunc=None)
    # Get a list of all files inside the directory
    files = list(
        listdir(dirs,
                recurse=True,
                dirs=True,
                symlinks=False,
                tn=options["tn"]))
    excludes = []
    # Exclude the files listed to exclude
    if len(options["excludes"]) > 0:
        excludes = exclude(files, options["excludes"])
    c = 0
    l = len(files)
    # Remove the wanted files
    for file_ in files:
        file__ = utilities.utf8(file_)
        file_ = utilities.utf8(os.path.basename(file__))
        if options["progressfunc"]:
            options["progressfunc"](utilities.calcPercent(c, l))
        c += 1
        # Make sure we don't remove files that are listed to exclude from removal
        if file__ in excludes:
            #logger.logVV(tn, logger.I, utilities.utf8all(file_, " ",
            #                                             _("is to be excluded. Skipping a CPU cycle")))
            continue
        fullpath = file__
        dfile = delink(fullpath)
        if dfile is None:
            if os.path.isfile(fullpath):
                rm(fullpath)
            elif os.path.isdir(fullpath) and options["remdirs"]:
                rm(fullpath)
        else:
            if options["remsymlink"]:
                if (os.path.isdir(fullpath)
                        and options["remdirs"]) or os.path.isfile(fullpath):
                    #logger.logVV(tn, logger.I, utilities.utf8all(_("Removing symlink"), " ", fullpath))
                    rm(fullpath)
            if options["remfullpath"]:
                #logger.logVV(tn, logger.I, utilities.utf8all(_("Removing"), " ", dfile, " (",
                #                                   _("directed by symlink"), fullpath, ")"))
                rm(dfile)
    if options["remdirs"] and options["remoriginal"]:
        #logger.logVV(tn, logger.I, utilities.utf8all(_("Removing source directory"), " ", dirs))
        rm(dirs)
Example #14
0
 def __init__(self, parent, *args, **kw):
     utilities.setDefault(
         kw,
         background=bg,
         foreground=fg,
         borderwidth=0,
         pady=6,
         padx=6,
         highlightbackground=_rgbtohex(normalc),
         highlightcolor=_rgbtohex(hoverc),
     )
     Tkinter.Label.__init__(self, parent, *args, **kw)
Example #15
0
 def __init__(self, parent, *args, **kw):
     self.value = Tkinter.IntVar()
     utilities.setDefault(kw,
                          background=bg,
                          borderwidth=0,
                          highlightthickness=0,
                          foreground=fg,
                          selectcolor=bg,
                          activebackground=bg,
                          activeforeground=fg,
                          variable=self.value)
     Tkinter.Checkbutton.__init__(self, parent, *args, **kw)
Example #16
0
def adrm(dirs, **options):
    utilities.setDefault(
        options,
        excludes=[],
        remdirs=True,
        remsymlink=True,
        remfullpath=False,
        remoriginal=True,
        tn="",
        progressfunc=None,
    )
    # Get a list of all files inside the directory
    files = list(listdir(dirs, recurse=True, dirs=True, symlinks=False, tn=options["tn"]))
    excludes = []
    # Exclude the files listed to exclude
    if len(options["excludes"]) > 0:
        excludes = exclude(files, options["excludes"])
    c = 0
    l = len(files)
    # Remove the wanted files
    for file_ in files:
        file__ = utilities.utf8(file_)
        file_ = utilities.utf8(os.path.basename(file__))
        if options["progressfunc"]:
            options["progressfunc"](utilities.calcPercent(c, l))
        c += 1
        # Make sure we don't remove files that are listed to exclude from removal
        if file__ in excludes:
            # logger.logVV(tn, logger.I, utilities.utf8all(file_, " ",
            #                                             _("is to be excluded. Skipping a CPU cycle")))
            continue
        fullpath = file__
        dfile = delink(fullpath)
        if dfile is None:
            if os.path.isfile(fullpath):
                rm(fullpath)
            elif os.path.isdir(fullpath) and options["remdirs"]:
                rm(fullpath)
        else:
            if options["remsymlink"]:
                if (os.path.isdir(fullpath) and options["remdirs"]) or os.path.isfile(fullpath):
                    # logger.logVV(tn, logger.I, utilities.utf8all(_("Removing symlink"), " ", fullpath))
                    rm(fullpath)
            if options["remfullpath"]:
                # logger.logVV(tn, logger.I, utilities.utf8all(_("Removing"), " ", dfile, " (",
                #                                   _("directed by symlink"), fullpath, ")"))
                rm(dfile)
    if options["remdirs"] and options["remoriginal"]:
        # logger.logVV(tn, logger.I, utilities.utf8all(_("Removing source directory"), " ", dirs))
        rm(dirs)
Example #17
0
 def __init__(self, parent, *args, **kw):
     if "savevar" in kw:
         self.savevar = kw.pop("savevar")
     if "savefunc" in kw:
         self.savefunc = kw.pop("savefunc")
     self.value = Tkinter.StringVar()
     utilities.setDefault(kw, background = bg, foreground = fg, selectbackground = fg,
                 selectforeground = bg, borderwidth = 0, highlightbackground = _rgbtohex(normalc),
                 highlightcolor = _rgbtohex(clickc), textvariable = self.value)
     self.lastcolor = normalc
     self.renderthread = None
     Tkinter.Entry.__init__(self, parent, *args, **kw)
     self.bind("<Enter>", self.hoveringtrue)
     self.bind("<Leave>", self.hoveringfalse)
     self.value.trace("w", self.save)
Example #18
0
def listdir(x, **options):
    utilities.setDefault(options, recurse=True, dirs=True, symlinks=False, tn="")
    if os.path.isdir(x):
        if options["dirs"]:
            yield utilities.utf8(x)
        for i in os.listdir(x):
            f = utilities.utf8(os.path.join(x, i))
            if os.path.isdir(f):
                if (os.path.islink(f) and not options["symlinks"]) or (not options["recurse"] and options["dirs"]):
                    yield f
                    continue
                for y in listdir(f, **options):
                    yield y
            else:
                yield f
Example #19
0
 def __init__(self, master=None, *args, **kw):
     self.master = master
     self.pages = []
     self.current = Tkinter.IntVar()
     self.current.set(0)
     self.old = 0
     self.finishedtb = None
     npages = kw.pop("npages", 0)
     utilities.setDefault(kw, background=bg, borderwidth=0, highlightthickness=0)
     Frame.__init__(self, master, *args, **kw)
     if npages > 0:
         for page in range(npages):
             self.add_empty_page()
         self.pages[self.current.get()].pack(fill="both", expand=1)
         self._tab_buttons()
     self.current.trace("w", self._select)
Example #20
0
 def __init__(self, master = None, *args, **kw):
     self.master = master
     self.pages = []
     self.current = Tkinter.IntVar()
     self.current.set(0)
     self.old = 0
     self.finishedtb = None
     npages = kw.pop('npages', 0)
     utilities.setDefault(kw, background = bg, borderwidth = 0, highlightthickness = 0)
     Frame.__init__(self, master, *args, **kw)
     if npages > 0:
         for page in range(npages):
             self.add_empty_page()
         self.pages[self.current.get()].pack(fill = 'both', expand = 1)
         self._tab_buttons()
     self.current.trace("w", self._select)
Example #21
0
 def __init__(self, parent, *args, **kw):
     utilities.setDefault(kw, background=bg, borderwidth=0, highlightthickness=0)
     Tkinter.Canvas.__init__(self, parent, *args, **kw)
     self.height = 0
     self.width = 0
     self.anim = 1.0
     self.c_top = self.create_line(0, 0, 0, self.height, fill="#000")
     self.c_left = self.create_line(0, 0, self.width, 0, fill="#000")
     self.c_bottom = []
     self.c_right = []
     self.setHeight(self.height)
     self.setWidth(self.width)
     self.finishrenderingcmd = None
     self.renderlock = Tkinter.IntVar()
     self.renderlock.set(0)
     self.busy = False
     self.lastcolor = (0, 0, 0)
     self.currrenderer = None
Example #22
0
 def __init__(self, parent, *args, **kw):
     utilities.setDefault(kw, background = bg, borderwidth = 0, highlightthickness = 0)
     Tkinter.Canvas.__init__(self, parent, *args, **kw)
     self.height = 0
     self.width = 0
     self.anim = 1.0
     self.c_top = self.create_line(0, 0, 0, self.height, fill = "#000")
     self.c_left = self.create_line(0, 0, self.width, 0, fill = "#000")
     self.c_bottom = []
     self.c_right = []
     self.setHeight(self.height)
     self.setWidth(self.width)
     self.finishrenderingcmd = None
     self.renderlock = Tkinter.IntVar()
     self.renderlock.set(0)
     self.busy = False
     self.lastcolor = (0, 0, 0)
     self.currrenderer = None
Example #23
0
 def __init__(self, parent, *args, **kw):
     self.command = kw.pop("command", None)
     bindclick = kw.pop("bindclick", True)
     bindunclick = kw.pop("bindunclick", True)
     self.mousedown = kw.pop("mousedown", None)
     utilities.setDefault(kw, background = bg, foreground = fg, borderwidth = 0, pady = 3, padx = 8,
                     highlightbackground = _rgbtohex(normalc), highlightthickness = 1)
     Tkinter.Label.__init__(self, parent, *args, **kw)
     self.lastcolor = normalc
     self.renderthread = None
     self.hovering = False
     self.clicking = False
     self.bind("<Enter>", self.hoveringtrue)
     self.bind("<Leave>", self.hoveringfalse)
     if bindclick:
         self.bind("<ButtonPress-1>", self.onclick)
     if bindunclick:
         self.bind("<ButtonRelease-1>", self.onunclick)
Example #24
0
def listdir(x, **options):
    utilities.setDefault(options,
                         recurse=True,
                         dirs=True,
                         symlinks=False,
                         tn="")
    if os.path.isdir(x):
        if options["dirs"]:
            yield utilities.utf8(x)
        for i in os.listdir(x):
            f = utilities.utf8(os.path.join(x, i))
            if os.path.isdir(f):
                if ((os.path.islink(f) and not options["symlinks"])
                        or (not options["recurse"] and options["dirs"])):
                    yield f
                    continue
                for y in listdir(f, **options):
                    yield y
            else:
                yield f
Example #25
0
def listdir(dirs, options = {}, tn = ""):
    utilities.setDefault(options, recurse = True, dirs = True, symlinks = False)
    logger.logV(tn, logger.I, utilities.utf8all(_("Gathering a list of files in"), " ", dirs))
    listed = []
    if options["recurse"]:
        listed = os.walk(utilities.utf8(dirs), True, None, options["symlinks"])
    else:
        listed = os.listdir(utilities.utf8(dirs))
    returnme = []
    for i in listed:
        if options["dirs"]:
            if options["recurse"]:
                returnme.append(utilities.utf8(i[0]))
            elif os.path.isdir(i):
                returnme.append(utilities.utf8(i))
        if options["recurse"]:
            for x in i[2]:
                returnme.append(utilities.utf8(os.path.join(i[0], x)))
        elif os.path.isfile(i) or os.path.islink(i):
            returnme.append(utilities.utf8(i))
    return returnme
Example #26
0
def listdir(dirs, options={}, tn=""):
    utilities.setDefault(options, recurse=True, dirs=True, symlinks=False)
    logger.logV(
        tn, logger.I,
        utilities.utf8all(_("Gathering a list of files in"), " ", dirs))
    listed = []
    if options["recurse"]:
        listed = os.walk(utilities.utf8(dirs), True, None, options["symlinks"])
    else:
        listed = os.listdir(utilities.utf8(dirs))
    returnme = []
    for i in listed:
        if options["dirs"]:
            if options["recurse"]:
                returnme.append(utilities.utf8(i[0]))
            elif os.path.isdir(i):
                returnme.append(utilities.utf8(i))
        if options["recurse"]:
            for x in i[2]:
                returnme.append(utilities.utf8(os.path.join(i[0], x)))
        elif os.path.isfile(i) or os.path.islink(i):
            returnme.append(utilities.utf8(i))
    return returnme
Example #27
0
def fscopy(src, dst, excludes1, tn="", **options):
    utilities.setDefault(options, progressfunc=None)
    src1 = re.sub(r"/+$", "", src)
    src = src1
    dst1 = re.sub(r"/+$", "", dst)
    dst = dst1
    dstp = re.sub(r"/+$", "", os.path.dirname(dst))
    # Get a list of all files
    files = list(listdir(src, tn=tn))
    # Get the length of the file list
    lfiles = len(files)
    # Exclude the files that are not wanted
    excludes = []
    if len(excludes1) > 0:
        excludes = exclude(files, excludes1)
    makedir(dst)
    c = 0
    # Copy the files
    for file___ in files:
        if options["progressfunc"]:
            options["progressfunc"](utilities.calcPercent(c, lfiles))
        c += 1
        file__ = utilities.utf8(os.path.abspath(file___))
        file_ = utilities.utf8(os.path.basename(utilities.utf8(file__)))
        # Make sure we don't copy files that are supposed to be excluded
        if file_ in excludes:
            # logger.logVV(tn, logger.W, utilities.utf8all(file_, " ", _("is to be excluded. Skipping a CPU cycle")))
            continue
        fullpath = utilities.utf8(file__)
        # print(dst + " " + file__[len(src):])
        temp = re.sub(r"^/+", "", file__[len(src) :])
        newpath = utilities.utf8(os.path.join(dst, temp))
        if not os.path.exists(fullpath):
            # Either an error on fsutil's part, or the file got deleted
            continue
        # Save some valuable time
        if os.path.exists(newpath):
            fpmd5 = genMD5(fullpath)
            npmd5 = genMD5(newpath)
            if fpmd5 == npmd5:
                continue
        dfile = delink(fullpath, False)
        if dfile is not None:
            """logger.logVV(tn, logger.D, utilities.utf8all(file_, " ",
                                            _("is a symlink. Creating an identical symlink at"), " ",
                                            newpath))
            logger.logI(
                tn, logger.D, utilities.utf8all("ORIGINAL ", dfile, "NEW ",
                                                        os.path.relpath(dfile, fullpath)))
            symlink(os.path.normpath("/" +
                                    abspath(
                                        os.path.relpath(
                                            dfile, fullpath), newpath)[len(
                                                dstp):]),
                                newpath)"""
            symlink(dfile, newpath)
        elif os.path.isdir(fullpath):
            # logger.logVV(tn, logger.I, utilities.utf8all(_("Creating directory"), " ", file_))
            makedir(newpath)
            # logger.logVV(tn, logger.I, _("Setting permissions"))
            copystat(fullpath, newpath)
        else:
            # logger.logVV(tn, logger.I, utilities.utf8all(_("Copying"), " ", fullpath, " ", _("to"), " ", newpath))
            try:
                shutil.copy2(fullpath, newpath)
            except Exception as e:
                print e
    # logger.logVV(tn, logger.I, _("Setting permissions"))
    copystat(src, dst)
Example #28
0
def fscopy(src, dst, excludes1, tn="", **options):
    utilities.setDefault(options, progressfunc=None)
    src1 = re.sub(r"/+$", "", src)
    src = src1
    dst1 = re.sub(r"/+$", "", dst)
    dst = dst1
    dstp = re.sub(r"/+$", "", os.path.dirname(dst))
    # Get a list of all files
    files = list(listdir(src, tn=tn))
    # Get the length of the file list
    lfiles = len(files)
    # Exclude the files that are not wanted
    excludes = []
    if len(excludes1) > 0:
        excludes = exclude(files, excludes1)
    makedir(dst)
    c = 0
    # Copy the files
    for file___ in files:
        if options["progressfunc"]:
            options["progressfunc"](utilities.calcPercent(c, lfiles))
        c += 1
        file__ = utilities.utf8(os.path.abspath(file___))
        file_ = utilities.utf8(os.path.basename(utilities.utf8(file__)))
        # Make sure we don't copy files that are supposed to be excluded
        if file_ in excludes:
            #logger.logVV(tn, logger.W, utilities.utf8all(file_, " ", _("is to be excluded. Skipping a CPU cycle")))
            continue
        fullpath = utilities.utf8(file__)
        #print(dst + " " + file__[len(src):])
        temp = re.sub(r"^/+", "", file__[len(src):])
        newpath = utilities.utf8(os.path.join(dst, temp))
        if not os.path.exists(fullpath):
            # Either an error on fsutil's part, or the file got deleted
            continue
        # Save some valuable time
        if os.path.exists(newpath):
            fpmd5 = genMD5(fullpath)
            npmd5 = genMD5(newpath)
            if fpmd5 == npmd5:
                continue
        dfile = delink(fullpath, False)
        if dfile is not None:
            '''logger.logVV(tn, logger.D, utilities.utf8all(file_, " ",
                                            _("is a symlink. Creating an identical symlink at"), " ",
                                            newpath))
            logger.logI(
                tn, logger.D, utilities.utf8all("ORIGINAL ", dfile, "NEW ",
                                                        os.path.relpath(dfile, fullpath)))
            symlink(os.path.normpath("/" +
                                    abspath(
                                        os.path.relpath(
                                            dfile, fullpath), newpath)[len(
                                                dstp):]),
                                newpath)'''
            symlink(dfile, newpath)
        elif os.path.isdir(fullpath):
            #logger.logVV(tn, logger.I, utilities.utf8all(_("Creating directory"), " ", file_))
            makedir(newpath)
            #logger.logVV(tn, logger.I, _("Setting permissions"))
            copystat(fullpath, newpath)
        else:
            #logger.logVV(tn, logger.I, utilities.utf8all(_("Copying"), " ", fullpath, " ", _("to"), " ", newpath))
            try:
                shutil.copy2(fullpath, newpath)
            except Exception as e:
                print e
    #logger.logVV(tn, logger.I, _("Setting permissions"))
    copystat(src, dst)
Example #29
0
 def __init__(self, parent, *args, **kw):
     utilities.setDefault(kw, highlightthickness=0, borderwidth=0, background=bg, relief=Tkinter.FLAT)
     Tkinter.Frame.__init__(self, parent, *args, **kw)