home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog Special Freeware 31
/
FreelogHS31.iso
/
ArgentCompta
/
Bankperfect
/
bp.exe
/
Scripts
/
Backups
/
backups.py
< prev
Wrap
Text File
|
2007-03-30
|
3KB
|
74 lines
import BP, nt, time
files = []
online = 0
def stat(path):
try:
if nt.lstat(path)[0] & 0170000 == 0040000: return 2
return 1
except:
return 0
def filedate(path):
d = time.gmtime(nt.lstat(path)[8])
return (d[0], d[1], d[2])
def restore(Sender):
i = List.ItemIndex
if i > -1:
s = BP.OpenDialog("Restaurer sous le nom...", "", ".bp", "Fichier BP|*.bp")
if s != "":
if stat(s) > 0: BP.MsgBox("Choisissez un autre nom :\nUn fichier portant ce nom existe dΘjα", 64)
else:
if online: BP.GetURL("ftp_get:%s|%s|default_bp_login|default_bp_password@default_bp_url" %(s, files[i][1]))
else: BP.GetURL("copy_file:%s|%s" %(b + files[i][1], s))
if BP.MsgBox("Le fichier a ΘtΘ crΘΘ.\nSouhaitez-vous l'ouvrir ?", 36) == 6:
BP.BankPerfectOpenFile(s, "")
f.Close()
def LoadFiles(Sender):
global files, online
LTitle.Caption = Sender.Caption
if Sender == BLocal:
online = 0
files = nt.listdir(b)
files = [(filedate(b + f), f) for f in files if stat(b + f) == 1 and f[-4:] == ".bp0"]
files.sort()
files.reverse()
List.Items.Text = "\n".join(["%.2d/%.2d/%.4d %s" %(f[0][2], f[0][1], f[0][0], f[1]) for f in files])
else:
online = 1
files = BP.GetURL("ftp_lst:default_bp_folder*.bp|default_bp_login|default_bp_password@default_bp_url").replace("\r\n", "\n").replace("\r", "\n").split("\n")
files = [f.split('|') for f in files]
files = [(f[2], f[1], f[3]) for f in files if f[0] == 'file']
files.sort()
files.reverse()
List.Items.Text = "\n".join(["%s/%s/%s %s (%s octets)" %(f[0][8:10], f[0][5:7], f[0][:4], f[1], f[2]) for f in files])
b = BP.GetURL("bp_backup_folder")
if b != "" and b[-1] != "\\": b += "\\"
f = CreateComponent("TForm", None)
f.SetProps(Position="poMainFormCenter", Width=520, Height=300, BorderStyle="bsSingle", BorderIcons=["biSystemMenu","biMinimize"], Caption="Liste des sauvegardes")
f.Font.Name = "Tahoma"
LTitle = CreateComponent("TLabel", f)
LTitle.SetProps(Parent=f, Left=40, Top=30, Caption="")
LTitle.Font.Style = ["fsBold"]
List = CreateComponent("TListBox", f)
List.SetProps(Parent=f, Left=40, Top=50, Width=430, Height=140, ItemIndex=-1)
BLocal = CreateComponent("TButton", f)
BLocal.SetProps(Parent=f, Left=40, Top=210, Width=120, Height=25, Caption="Sauvegardes locales", OnClick=LoadFiles)
BFTP = CreateComponent("TButton", f)
BFTP.SetProps(Parent=f, Left=170, Top=210, Width=120, Height=25, Caption="Sauvegardes FTP", OnClick=LoadFiles)
BRestore = CreateComponent("TButton", f)
BRestore.SetProps(Parent=f, Left=300, Top=210, Width=80, Height=25, Caption="Restaurer", OnClick=restore)
BOK = CreateComponent("TButton", f)
BOK.SetProps(Parent=f, Left=390, Top=210, Width=80, Height=25, Caption="Fermer", ModalResult=1, Default=1, Cancel=1)
LoadFiles(BLocal)
f.ShowModal()