1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
| def onExport(self,event):
print "jo"
export = "Export" + " " + self.siteName
##get the list of selected items
print "entrée dans export"
listOfSelectedItemIdx=[]
listOfSelectedItemText=[] ##useless ????
listOfSelectedItems=[]
item = -1
while True:
item = self.listCtrl.list.GetNextItem(item,wx.LIST_NEXT_ALL,wx.LIST_STATE_SELECTED)
if item == -1:
break
## this item is selected - do whatever is needed with it
print "Item "+str(item)+" is selected."
listOfSelectedItemIdx.append(item)
if listOfSelectedItemIdx == []:
dlg = wx.MessageDialog(self, 'Please Select Lines',
'Warning',
wx.OK | wx.ICON_INFORMATION
#wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
)
dlg.ShowModal()
dlg.Destroy()
for idx in listOfSelectedItemIdx:
itemText=self.listCtrl.list.GetItemText(idx)
listOfSelectedItemText.append(itemText)
listOfSelectedItems.append(self.smg.listModifs[itemText])
self.smg.listModifs[self.currentItemText]
exportSmg=Smog()
for idx in listOfSelectedItemIdx:
itemText = self.listCtrl.list.GetItemText(idx)
exportSmg.importModif(itemText,self.smg.listModifs[itemText])
if os.path.exists(export):
dlg = wx.MessageDialog(self, 'Folder is already existing! Please Remove this file to do this Operation',
'Warning',
wx.OK | wx.ICON_INFORMATION
#wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
)
dlg.ShowModal()
dlg.Destroy()
##Récuperer le nom du dossier et le nom du fichier
export = "Export" + " " + self.siteName
self.exportFolder = os.path.join(self.dirName,export)
os.mkdir(self.exportFolder)
self.itemsSelectedNameFile = self.fileNameShort
self.itemsSelectedFile = os.path.join(self.exportFolder,self.itemsSelectedNameFile)
##sauver exportSmg dans le fichier
output = open(self.itemsSelectedFile,'wb')
cPickle.dump(exportSmg,output)
output.close()
##créer le dossier image
self.itemsSelectedUnderFolder = os.path.join(self.exportFolder,self.siteName)
os.mkdir(self.itemsSelectedUnderFolder)
self.copyPicturesFolder = "Pictures"
self.copyPicturesFolder = os.path.join(self.itemsSelectedUnderFolder,self.copyPicturesFolder)
os.mkdir(self.copyPicturesFolder)
self.copySmallPicturesFolder = "Small Pictures"
self.copySmallPicturesFolder = os.path.join(self.itemsSelectedUnderFolder,self.copySmallPicturesFolder)
os.mkdir(self.copySmallPicturesFolder)
##sauver les images
print listOfSelectedItemText
for currentItemText in listOfSelectedItemText :
image1Name = currentItemText + '-' + 'image1.png'
image2Name = currentItemText + '-' + 'image2.png'
image3Name = currentItemText + '-' + 'image3.png'
bigImage1 = os.path.join(self.dirBigPictureFolderComplete,image1Name)
bigImage2 = os.path.join(self.dirBigPictureFolderComplete,image2Name)
bigImage3 = os.path.join(self.dirBigPictureFolderComplete,image3Name)
image1 = os.path.join(self.dirPictureFolderComplete,image1Name)
image2 = os.path.join(self.dirPictureFolderComplete,image2Name)
image3 = os.path.join(self.dirPictureFolderComplete,image3Name)
if os.path.exists(bigImage1):
shutil.copy(bigImage1,self.copyPicturesFolder)
else :
print "no" + bigImage1
if os.path.exists(bigImage2):
shutil.copy(bigImage2,self.copyPicturesFolder)
else :
print "no" + bigImage2
if os.path.exists(bigImage3):
shutil.copy(bigImage3,self.copyPicturesFolder)
else :
print "no" + bigImage3
if os.path.exists(image1):
shutil.copy(image1,self.copySmallPicturesFolder)
else :
print "no" + image1
if os.path.exists(image2):
shutil.copy(image2,self.copySmallPicturesFolder)
else :
print "no" + image2
if os.path.exists(image3):
shutil.copy(image3,self.copySmallPicturesFolder)
else :
print "no" + image3
## Copy of all auxiliaries Files
self.textFileData = self.siteName + ".txt"
self.maxRefLine = os.path.join(self.dirFolderComplete,self.textFileData)
shutil.copy(self.maxRefLine,self.itemsSelectedUnderFolder)
self.initPictureName = "blanc.png"
self.initPictureFileName = os.path.join(self.itemsSelectedUnderFolder,self.initPictureName)
a = Image.new('L', (200, 200), 255)
a.save(self.initPictureFileName)
#créer un zip
Selectionner le chemin du zip
self.zipName = "Export jo.zip"
self.locatedZipFile = os.path.join(self.dirName,self.zipName)
#
# if os.path.exists(self.exportFolder):
file = zipfile.ZipFile(self.locatedZipFile,'w',zipfile.ZIP_DEFLATED)
file.write("D:\ProjetsPCS7")
file.close() |
Partager