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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924
| #!/usr/bin/python
#-*- coding: iso-8859-15 -*-
import pickle
from time import gmtime, strftime
import time
from datetime import datetime
import wx #importe le module graphique wx
import os
from os.path import *
from os import getcwd #importe la fonction qui recupere le chemin du repertoire
from wx.lib.intctrl import IntCtrl
import thread
import psutil
#Vars Triggers
Apache_on=0
CH_set=0
CM_set=0
CS_set=0
IH_set=0
IM_set=0
IS_set=0
MH_set=0
MM_set=0
MS_set=0
count_c=0
count_i=0
count_m=0
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, None, id, u"MAGENTOOLS V1.0 par François GARBEZ", wx.DefaultPosition, wx.Size(900, 830),style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)
chemin=getcwd()+"\\img"
ico = wx.Icon(chemin+"\\icone32.ico", wx.BITMAP_TYPE_ICO)
self.SetIcon(ico)
#Panel pour affichage
self.panel = wx.Panel(self, -1)
#Crée la barre d'état (en bas).
self.CreerBarreEtat()
#Boutons
self.buttonParcourir = wx.Button(self.panel,-1,u"PARCOURIR")
self.Bind(wx.EVT_BUTTON, self.Parcourir, self.buttonParcourir)
self.buttonCreateBatch = wx.Button(self.panel,-1,u"CREER BATCHS")
self.Bind(wx.EVT_BUTTON, self.CreateBatch, self.buttonCreateBatch)
self.buttonAllocMem= wx.Button(self.panel,-1,u"ALLOUER MEMOIRE")
self.Bind(wx.EVT_BUTTON, self.AllocMem, self.buttonAllocMem)
self.buttonCleanFlush = wx.Button(self.panel,-1,u"CACHE CLEAN/FLUSH")
self.Bind(wx.EVT_BUTTON, self.CleanFlush, self.buttonCleanFlush)
self.buttonOutilMem = wx.Button(self.panel,-1,u"OUTIL MEMOIRE")
self.Bind(wx.EVT_BUTTON, self.OutilMem, self.buttonOutilMem)
self.buttonOutilIndex = wx.Button(self.panel,-1,u"OUTIL REINDEX")
self.Bind(wx.EVT_BUTTON, self.OutilIndex, self.buttonOutilIndex)
self.buttonDesinstalle = wx.Button(self.panel,-1,u"DESINSTALLER MAGENTO")
self.Bind(wx.EVT_BUTTON, self.Desinstalle, self.buttonDesinstalle)
self.buttonApacheState = wx.Button(self.panel,-1,u"CHECK APACHE")
self.Bind(wx.EVT_BUTTON, self.ApacheState, self.buttonApacheState)
self.buttonCronClean= wx.Button(self.panel,-1,u"START !")
self.Bind(wx.EVT_BUTTON, self.CronClean, self.buttonCronClean)
self.buttonCronIndex= wx.Button(self.panel,-1,u"START !")
self.Bind(wx.EVT_BUTTON, self.CronIndex, self.buttonCronIndex)
self.buttonCronMem= wx.Button(self.panel,-1,u"START !")
self.Bind(wx.EVT_BUTTON, self.CronMem, self.buttonCronMem)
self.buttonStopCronClean= wx.Button(self.panel,-1,u"STOP !")
self.Bind(wx.EVT_BUTTON, self.StopCronClean, self.buttonStopCronClean)
self.buttonStopCronIndex= wx.Button(self.panel,-1,u"STOP !")
self.Bind(wx.EVT_BUTTON, self.StopCronIndex, self.buttonStopCronIndex)
self.buttonStopCronMem= wx.Button(self.panel,-1,u"STOP !")
self.Bind(wx.EVT_BUTTON, self.StopCronMem, self.buttonStopCronMem)
self.buttonResetCleanTimer= wx.Button(self.panel,-1,u"RESET TIMER CLEAN")
self.Bind(wx.EVT_BUTTON, self.ResetCleanTimer, self.buttonResetCleanTimer)
self.buttonResetIndexTimer= wx.Button(self.panel,-1,u"RESET TIMER INDEX")
self.Bind(wx.EVT_BUTTON, self.ResetIndexTimer, self.buttonResetIndexTimer)
self.buttonResetMemTimer= wx.Button(self.panel,-1,u"RESET TIMER MEMO")
self.Bind(wx.EVT_BUTTON, self.ResetMemTimer, self.buttonResetMemTimer)
#widgets vides
self.txtVideParcourir = wx.StaticText(self.panel,-1,"",style=wx.TE_MULTILINE)
self.txtVideCreateBatch = wx.StaticText(self.panel,-1,"")
self.txtVideApacheState = wx.StaticText(self.panel,-1,"")
self.txtVideCronClean= wx.StaticText(self.panel,-1,"")
self.txtVideCronIndex= wx.StaticText(self.panel,-1,"")
self.txtVideCronMem= wx.StaticText(self.panel,-1,"")
#widgets
self.ParcourirText=wx.StaticText(self.panel, -1, u"I-Définir le chemin d'installation de MAGENTO (fichier magento)\n-Exemple: C:\wamp64\www\magento2\\bin\magento \n-Cette étape est IMPERATIVE !")
self.ParcourirText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.CurrentPathText=wx.StaticText(self.panel, -1, u"Chemin d'accès (PATH) actuellement sélectionné pour MAGENTO :")
self.CurrentPathText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.CreateBatchText=wx.StaticText(self.panel, -1, u"II-Paramétrer et Créer les BATCHS")
self.CreateBatchText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
#IntCtrl
self.MemorySizeEntry=IntCtrl(self.panel,-1,value = 1,style=wx.TE_PROCESS_ENTER,min=1,max=1024,limited=True,size=(40,20))
self.CleanTimerEntryH=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=23,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetCleanTimerH,self.CleanTimerEntryH)
self.CleanTimerEntryM=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=59,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetCleanTimerM,self.CleanTimerEntryM)
self.CleanTimerEntryS=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=59,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetCleanTimerS,self.CleanTimerEntryS)
self.IndexTimerEntryH=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=23,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetIndexTimerH,self.IndexTimerEntryH)
self.IndexTimerEntryM=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=59,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetIndexTimerM,self.IndexTimerEntryM)
self.IndexTimerEntryS=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=59,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetIndexTimerS,self.IndexTimerEntryS)
self.MemTimerEntryH=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=23,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetMemTimerH,self.MemTimerEntryH)
self.MemTimerEntryM=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=59,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetMemTimerM,self.MemTimerEntryM)
self.MemTimerEntryS=IntCtrl(self.panel,-1,value = 0,style=wx.TE_PROCESS_ENTER,min=0,max=59,limited=True,size=(25,20))
self.Bind(wx.EVT_TEXT_ENTER,self.SetMemTimerS,self.MemTimerEntryS)
####
self.MemorySizeText=wx.StaticText(self.panel, -1, u"Mémoire allouée à MAGENTO (max 1024 GB):")
self.MemorySizeText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.MemorySizeText2=wx.StaticText(self.panel, -1, u"Validez en appuyant sur 'Entrée' !")
self.MemorySizeText2.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.UseBatchText=wx.StaticText(self.panel, -1, u"III-Utiliser les BATCHS et CRON")
self.UseBatchText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.Unit_UseBatchText=wx.StaticText(self.panel, -1, u"Lancements unitaires :")
self.Unit_UseBatchText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.ApacheStateText=wx.StaticText(self.panel, -1, u"Check serveur Apache :")
self.ApacheStateText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.CronText=wx.StaticText(self.panel, -1, u"Tâches planifiées(CRON) :")
self.CronText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.ChronoText=wx.StaticText(self.panel, -1, u"Affichage des Chronos :")
self.ChronoText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.CleanTimerText=wx.StaticText(self.panel, -1, u"TIMER CLEAN :")
self.CleanTimerText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.IndexTimerText=wx.StaticText(self.panel, -1, u"TIMER INDEX :")
self.IndexTimerText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.MemTimerText=wx.StaticText(self.panel, -1, u"TIMER MEMO :")
self.MemTimerText.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.CleanTimerTextH=wx.StaticText(self.panel, -1, u"Heure(s)")
self.CleanTimerTextH.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.CleanTimerTextM=wx.StaticText(self.panel, -1, u"Minute(s)")
self.CleanTimerTextM.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.CleanTimerTextS=wx.StaticText(self.panel, -1, u"Seconde(s)")
self.CleanTimerTextS.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.IndexTimerTextH=wx.StaticText(self.panel, -1, u"Heure(s)")
self.IndexTimerTextH.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.IndexTimerTextM=wx.StaticText(self.panel, -1, u"Minute(s)")
self.IndexTimerTextM.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.IndexTimerTextS=wx.StaticText(self.panel, -1, u"Seconde(s)")
self.IndexTimerTextS.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.MemTimerTextH=wx.StaticText(self.panel, -1, u"Heure(s)")
self.MemTimerTextH.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.MemTimerTextM=wx.StaticText(self.panel, -1, u"Minute(s)")
self.MemTimerTextM.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
self.MemTimerTextS=wx.StaticText(self.panel, -1, u"Seconde(s)")
self.MemTimerTextS.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ));
#Checkbox
self.CheckBoxClean=wx.CheckBox(self.panel,-1,"CRON Clean/Flush")
self.CheckBoxIndex=wx.CheckBox(self.panel,-1,"CRON Reindex")
self.CheckBoxMem=wx.CheckBox(self.panel,-1,"CRON Memory")
#Sizers
gbox1 = wx.GridBagSizer(10,10)
gbox1.SetEmptyCellSize((10,10))
gbox1.Add(self.ParcourirText,(0,0))
gbox1.Add(self.CurrentPathText,(1,0))
gbox1.Add(self.buttonParcourir,(0,1))
gbox1.Add(self.txtVideParcourir,(1,1))
gbox2 = wx.GridBagSizer(10,10)
gbox2.SetEmptyCellSize((10,10))
gbox2.Add(self.CreateBatchText,(0,0))
gbox2.Add(self.MemorySizeText,(1,0))
gbox2.Add(self.MemorySizeText2,(2,0))
gbox2.Add(self.MemorySizeEntry,(1,1))
gbox2.Add(self.buttonAllocMem,(2,1))
gbox2.Add(self.buttonCreateBatch,(2,2))
gbox2.Add(self.txtVideCreateBatch,(1,3))
gbox3 = wx.GridBagSizer(10,10)
gbox3.SetEmptyCellSize((10,10))
gbox3.Add(self.CleanTimerText,(0,0))
gbox3.Add(self.IndexTimerText,(0,2))
gbox3.Add(self.MemTimerText,(0,4))
gbox3.Add(self.CleanTimerEntryH,(1,0),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.CleanTimerEntryM,(2,0),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.CleanTimerEntryS,(3,0),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.CleanTimerTextH,(1,1))
gbox3.Add(self.CleanTimerTextM,(2,1))
gbox3.Add(self.CleanTimerTextS,(3,1))
gbox3.Add(self.IndexTimerEntryH,(1,2),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.IndexTimerEntryM,(2,2),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.IndexTimerEntryS,(3,2),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.IndexTimerTextH,(1,3))
gbox3.Add(self.IndexTimerTextM,(2,3))
gbox3.Add(self.IndexTimerTextS,(3,3))
gbox3.Add(self.MemTimerEntryH,(1,4),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.MemTimerEntryM,(2,4),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.MemTimerEntryS,(3,4),flag=wx.ALIGN_RIGHT)
gbox3.Add(self.MemTimerTextH,(1,5))
gbox3.Add(self.MemTimerTextM,(2,5))
gbox3.Add(self.MemTimerTextS,(3,5))
gbox3.Add(self.buttonResetCleanTimer,(1,10))
gbox3.Add(self.buttonResetIndexTimer,(2,10))
gbox3.Add(self.buttonResetMemTimer,(3,10))
gbox4 = wx.GridBagSizer(10,10)
gbox4.SetEmptyCellSize((10,10))
gbox4.Add(self.UseBatchText,(0,0))
gbox4.Add(self.ApacheStateText,(1,0))
gbox4.Add(self.buttonApacheState,(2,0))
gbox4.Add(self.txtVideApacheState,(3,0))
gbox4.Add(self.Unit_UseBatchText,(1,1))
gbox4.Add(self.buttonCleanFlush,(2,1))
gbox4.Add(self.buttonOutilIndex,(3,1))
gbox4.Add(self.buttonOutilMem,(4,1))
gbox4.Add(self.CronText,(1,2))
gbox4.Add(self.CheckBoxClean,(2,2))
gbox4.Add(self.CheckBoxIndex,(3,2))
gbox4.Add(self.CheckBoxMem,(4,2))
gbox4.Add(self.ChronoText,(1,3))
gbox4.Add(self.txtVideCronClean,(2,3))
gbox4.Add(self.txtVideCronIndex,(3,3))
gbox4.Add(self.txtVideCronMem,(4,3))
gbox4.Add(self.buttonCronClean,(2,4))
gbox4.Add(self.buttonCronIndex,(3,4))
gbox4.Add(self.buttonCronMem,(4,4))
gbox4.Add(self.buttonStopCronClean,(2,5))
gbox4.Add(self.buttonStopCronIndex,(3,5))
gbox4.Add(self.buttonStopCronMem,(4,5))
gbox5 = wx.GridBagSizer(10,10)
gbox5.SetEmptyCellSize((10,10))
gbox5.Add(self.buttonDesinstalle,(0,0))
#Définir chemin MAGENTO
box1 = wx.StaticBox(self.panel, -1, u"Définition du PATH de MAGENTO :")
bsizer1 = wx.StaticBoxSizer(box1, wx.HORIZONTAL)
sizerH1 = wx.BoxSizer(wx.VERTICAL)
sizerH1.Add(gbox1, 0, wx.ALL, 10)
bsizer1.Add(sizerH1, 1, wx.EXPAND, 0)
#Créer BATCHS
box2 = wx.StaticBox(self.panel, -1, u"Création des BATCHS :")
bsizer2 = wx.StaticBoxSizer(box2, wx.HORIZONTAL)
sizerH2 = wx.BoxSizer(wx.VERTICAL)
sizerH2.Add(gbox2, 0, wx.ALL, 10)
bsizer2.Add(sizerH2, 1, wx.EXPAND, 0)
#Définir les TIMERS
box3= wx.StaticBox(self.panel, -1, u"Réglages des TIMERS :")
bsizer3 = wx.StaticBoxSizer(box3, wx.HORIZONTAL)
sizerH3 = wx.BoxSizer(wx.VERTICAL)
sizerH3.Add(gbox3,0, wx.ALL, 10)
bsizer3.Add(sizerH3, 1, wx.EXPAND, 0)
#Lancer BATCHS
box4 = wx.StaticBox(self.panel, -1, u"Lancements des BATCHS :")
bsizer4 = wx.StaticBoxSizer(box4, wx.HORIZONTAL)
sizerH4 = wx.BoxSizer(wx.VERTICAL)
sizerH4.Add(gbox4,0, wx.ALL, 10)
bsizer4.Add(sizerH4, 1, wx.EXPAND, 0)
#Desinstallation
box5 = wx.StaticBox(self.panel, -1, u"Désinstallation de MAGENTO :")
bsizer5 = wx.StaticBoxSizer(box5, wx.HORIZONTAL)
sizerH5 = wx.BoxSizer(wx.VERTICAL)
sizerH5.Add(gbox5,0, wx.ALL|wx.CENTER, 10)
bsizer5.Add(sizerH5, 1, wx.EXPAND, 0)
#--------Ajustement des sizers----------
mainSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(bsizer1, 0,wx.ALL|wx.EXPAND, 10)
mainSizer.Add(bsizer2, 0,wx.ALL|wx.EXPAND, 10)
mainSizer.Add(bsizer3, 0,wx.ALL|wx.EXPAND, 10)
mainSizer.Add(bsizer4, 0,wx.ALL|wx.EXPAND, 10)
mainSizer.Add(bsizer5, 0,wx.ALL|wx.EXPAND, 10)
self.SetSizer(mainSizer)
#Init Repertoires
self.VerifRep()
#Init VARIABLES
self.Init_vars()
#Affiche PATH de MAGENTO
self.AfficheChemin()
#Fonctions
def ResetCleanTimer(self,evt):
global CH_set,CM_set,CS_set
self.CleanTimerEntryH.Enable()
self.CleanTimerEntryM.Enable()
self.CleanTimerEntryS.Enable()
self.CleanTimerEntryH.SetValue(0)
self.CleanTimerEntryM.SetValue(0)
self.CleanTimerEntryS.SetValue(0)
self.buttonCronClean.Disable()
CH_set=0
CM_set=0
CS_set=0
evt.Skip()
def ResetIndexTimer(self,evt):
global IH_set,IM_set,IS_set
self.IndexTimerEntryH.Enable()
self.IndexTimerEntryM.Enable()
self.IndexTimerEntryS.Enable()
self.IndexTimerEntryH.SetValue(0)
self.IndexTimerEntryM.SetValue(0)
self.IndexTimerEntryS.SetValue(0)
self.buttonCronIndex.Disable()
IH_set=0
IM_set=0
IS_set=0
evt.Skip()
def ResetMemTimer(self,evt):
global MH_set,MM_set,MS_set
self.MemTimerEntryH.Enable()
self.MemTimerEntryM.Enable()
self.MemTimerEntryS.Enable()
self.MemTimerEntryH.SetValue(0)
self.MemTimerEntryM.SetValue(0)
self.MemTimerEntryS.SetValue(0)
self.buttonCronMem.Disable()
MH_set=0
MM_set=0
MS_set=0
evt.Skip()
def SetCleanTimerH(self,evt):
global CleanH,CH_set,CM_set,CS_set
CleanH=self.CleanTimerEntryH.GetValue()
self.CleanTimerEntryH.Disable()
CH_set=1
if (CH_set==1)and(CM_set==1)and(CS_set==1):
self.buttonCronClean.Enable()
evt.Skip()
def SetCleanTimerM(self,evt):
global CleanM,CM_set,CH_set,CS_set
CleanM=self.CleanTimerEntryM.GetValue()
self.CleanTimerEntryM.Disable()
CM_set=1
if (CH_set==1)and(CM_set==1)and(CS_set==1):
self.buttonCronClean.Enable()
evt.Skip()
def SetCleanTimerS(self,evt):
global CleanS,CS_set,CM_set,CH_set
CleanS=self.CleanTimerEntryS.GetValue()
self.CleanTimerEntryS.Disable()
CS_set=1
if (CH_set==1)and(CM_set==1)and(CS_set==1):
self.buttonCronClean.Enable()
evt.Skip()
def SetIndexTimerH(self,evt):
global IndexH,IH_set,IM_set,IS_set
IndexH=self.IndexTimerEntryH.GetValue()
self.IndexTimerEntryH.Disable()
IH_set=1
if(IH_set==1)and(IM_set==1)and(IS_set==1):
self.buttonCronIndex.Enable()
evt.Skip()
def SetIndexTimerM(self,evt):
global IndexM,IM_set,IH_set,IS_set
IndexM=self.IndexTimerEntryM.GetValue()
self.IndexTimerEntryM.Disable()
IM_set=1
if(IH_set==1)and(IM_set==1)and(IS_set==1):
self.buttonCronIndex.Enable()
evt.Skip()
def SetIndexTimerS(self,evt):
global IndexS,IS_set,IM_set,IH_set
IndexS=self.IndexTimerEntryS.GetValue()
self.IndexTimerEntryS.Disable()
IS_set=1
if(IH_set==1)and(IM_set==1)and(IS_set==1):
self.buttonCronIndex.Enable()
evt.Skip()
def SetMemTimerH(self,evt):
global MemH,MH_set,MM_set,MS_set
MemH=self.MemTimerEntryH.GetValue()
self.MemTimerEntryH.Disable()
MH_set=1
if(MH_set==1)and(MM_set==1)and(MS_set==1):
self.buttonCronMem.Enable()
evt.Skip()
def SetMemTimerM(self,evt):
global MemM,MM_set,MH_set,MS_set
MemM=self.MemTimerEntryM.GetValue()
self.MemTimerEntryM.Disable()
MM_set=1
if(MH_set==1)and(MM_set==1)and(MS_set==1):
self.buttonCronMem.Enable()
evt.Skip()
def SetMemTimerS(self,evt):
global MemS,MS_set,MM_set,MH_et
MemS=self.MemTimerEntryS.GetValue()
self.MemTimerEntryS.Disable()
MS_set=1
if(MH_set==1)and(MM_set==1)and(MS_set==1):
self.buttonCronMem.Enable()
evt.Skip()
def StopCronClean(self,evt):
try:
self.timerClean.Stop()
self.buttonResetCleanTimer.Enable()
self.buttonCronClean.Enable()
self.buttonStopCronClean.Disable()
self.txtVideCronClean.SetLabel(u"0H 0Min 0sec")
self.txtVideCronClean.Refresh()
except:
pass
evt.Skip()
def StopCronIndex(self,evt):
try:
self.timerIndex.Stop()
self.buttonResetIndexTimer.Enable()
self.buttonCronIndex.Enable()
self.buttonStopCronIndex.Disable()
self.txtVideCronIndex.SetLabel(u"0H 0Min 0sec")
self.txtVideCronIndex.Refresh()
except:
pass
evt.Skip()
def StopCronMem(self,evt):
try:
self.timerMem.Stop()
self.buttonResetMemTimer.Enable()
self.buttonCronMem.Enable()
self.buttonStopCronMem.Disable()
self.txtVideCronMem.SetLabel(u"0H 0Min 0sec")
self.txtVideCronMem.Refresh()
except:
pass
evt.Skip()
def CronClean(self,evt):
global TzeroClean,CH_set,CM_set,CS_set
if Apache_on==1:
if (CH_set==1)and(CM_set==1)and(CS_set==1):
self.timerClean=wx.Timer(self, -1)
self.timerClean.Start(500)
TzeroClean=time.time()
self.Bind(wx.EVT_TIMER, self.ChronoClean, self.timerClean)
self.buttonResetCleanTimer.Disable()
self.buttonCronClean.Disable()
self.buttonStopCronClean.Enable()
else:
self.ErrorTimer()
else:
self.ErrorApache()
evt.Skip()
def ChronoClean(self,evt):
global TzeroClean,CleanH,CleanM,CleanS,count_c
tempsP=time.time()
diffTemps = tempsP-TzeroClean
diffTup = time.gmtime(diffTemps)
tempsF="%iH %iMin %isec" % ( diffTup.tm_hour, diffTup.tm_min, diffTup.tm_sec)
self.txtVideCronClean.SetLabel(tempsF+u" Nb="+str(count_c))
self.txtVideCronClean.Refresh()
if tempsF==str(CleanH)+u"H "+str(CleanM)+u"Min "+str(CleanS)+u"sec":
self.timerClean.Stop()
self.CleanFlush(evt)
evt.Skip()
def CronIndex(self,evt):
global TzeroIndex,IH_set,IM_set,IS_set
if Apache_on==1:
if (IH_set==1)and(IM_set==1)and(IS_set==1):
self.timerIndex=wx.Timer(self, -1)
self.timerIndex.Start(500)
TzeroIndex=time.time()
self.Bind(wx.EVT_TIMER, self.ChronoIndex, self.timerIndex)
self.buttonResetIndexTimer.Disable()
self.buttonCronIndex.Disable()
self.buttonStopCronIndex.Enable()
else:
self.ErrorTimer()
else:
self.ErrorApache()
evt.Skip()
def ChronoIndex(self,evt):
global TzeroIndex,IndexH,IndexM,IndexS,count_i
tempsP=time.time()
diffTemps = tempsP-TzeroIndex
diffTup = time.gmtime(diffTemps)
tempsF="%iH %iMin %isec" % ( diffTup.tm_hour, diffTup.tm_min, diffTup.tm_sec)
self.txtVideCronIndex.SetLabel(tempsF+u" Nb="+str(count_i))
self.txtVideCronIndex.Refresh()
if tempsF==str(IndexH)+u"H "+str(IndexM)+u"Min "+str(IndexS)+u"sec":
self.timerIndex.Stop()
self.OutilIndex(evt)
evt.Skip()
def CronMem(self,evt):
global TzeroMem,MH_set,MM_set,MS_set
if Apache_on==1:
if (MH_set==1)and(MM_set==1)and(MS_set==1):
self.timerMem=wx.Timer(self, -1)
self.timerMem.Start(500)
TzeroMem=time.time()
self.Bind(wx.EVT_TIMER, self.ChronoMem, self.timerMem)
self.buttonResetMemTimer.Disable()
self.buttonCronMem.Disable()
self.buttonStopCronMem.Enable()
else:
self.ErrorTimer()
else:
self.ErrorApache()
evt.Skip()
def ChronoMem(self,evt):
global TzeroMem,MemH,MemM,MemS,count_m
tempsP=time.time()
diffTemps = tempsP-TzeroMem
diffTup = time.gmtime(diffTemps)
tempsF="%iH %iMin %isec" % ( diffTup.tm_hour, diffTup.tm_min, diffTup.tm_sec)
self.txtVideCronMem.SetLabel(tempsF+u" Nb="+str(count_m))
self.txtVideCronMem.Refresh()
if tempsF==str(MemH)+u"H "+str(MemM)+u"Min "+str(MemS)+u"sec":
self.timerMem.Stop()
self.OutilMem(evt)
evt.Skip()
def ApacheState(self,evt):
global Apache_on
count=0
for p in psutil.process_iter():
pi = p.as_dict(attrs=['pid', 'name'])
if pi['name'] == 'httpd.exe':
count+=1
if count!=0:
Apache_on=1
self.txtVideApacheState.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ))
self.txtVideApacheState.SetForegroundColour(u"sea green")#On peut choisir la couleur(red,white,blue....)
self.txtVideApacheState.SetLabel("Apache ON !")
else:
Apache_on=0
self.txtVideApacheState.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ))
self.txtVideApacheState.SetForegroundColour(u"red")#On peut choisir la couleur(red,white,blue....)
self.txtVideApacheState.SetLabel("Apache OFF !")
evt.Skip()
def ErrorTimer(self):
dlg = wx.MessageDialog(self,u"Les TIMERS n'ont pas été crées !!!\nVous ne pouvez pas continuer !",u"Erreur de création de TIMERS !",\
style=wx.ICON_ERROR|wx.STAY_ON_TOP|wx.CENTER|wx.OK) #Definit les attributs de la fenetre de message.
dlg.ShowModal()
def ErrorBatch(self):
dlg = wx.MessageDialog(self,u"Les BATCHS n'ont pas été crées !!!\nVous ne pouvez pas continuer !",u"Erreur de création de BATCHS !",\
style=wx.ICON_ERROR|wx.STAY_ON_TOP|wx.CENTER|wx.OK) #Definit les attributs de la fenetre de message.
dlg.ShowModal()
def ErrorApache(self):
dlg = wx.MessageDialog(self,u"Le serveur APACHE n'est pas checké ou lancé !!!\nVous ne pouvez pas continuer !",u"Erreur connexion serveur !",\
style=wx.ICON_ERROR|wx.STAY_ON_TOP|wx.CENTER|wx.OK) #Definit les attributs de la fenetre de message.
dlg.ShowModal()
def CleanFlush(self,evt):
global rep_batchs,created_batchs,Apache_on,count_c
if created_batchs==1:
if Apache_on==1:
OriginePath=os.getcwd()
os.chdir(getcwd()+r"\batchs")
thread.start_new_thread(os.system,("magento-cache-cleaner.bat",))
time.sleep(1)
thread.start_new_thread(os.chdir,(OriginePath,))
count_c+=1
if self.CheckBoxClean.IsChecked()==True:
self.CronClean(evt)
else:
self.timerClean.Stop()
else:
self.ErrorApache()
else:
self.ErrorBatch()
evt.Skip()
def OutilIndex(self,evt):
global rep_batchs,created_batchs,Apache_on,count_i
if created_batchs==1:
if Apache_on==1:
OriginePath=os.getcwd()
os.chdir(getcwd()+r"\batchs")
thread.start_new_thread(os.system,("magento-reindexer.bat",))
time.sleep(1)
thread.start_new_thread(os.chdir,(OriginePath,))
count_i+=1
if self.CheckBoxIndex.IsChecked()==True:
self.CronIndex(evt)
else:
self.timerIndex.Stop()
else:
self.ErrorApache()
else:
self.ErrorBatch()
evt.Skip()
def OutilMem(self,evt):
global rep_batchs,created_batchs,Apache_on,count_m
if created_batchs==1:
if Apache_on==1:
OriginePath=os.getcwd()
os.chdir(getcwd()+r"\batchs")
thread.start_new_thread(os.system,("magento-memory-size-definer.bat",))
time.sleep(1)
thread.start_new_thread(os.chdir,(OriginePath,))
count_m+=1
if self.CheckBoxMem.IsChecked()==True:
self.CronMem(evt)
else:
self.timerMem.Stop()
else:
self.ErrorApache()
else:
self.ErrorBatch()
evt.Skip()
def Desinstalle(self,evt):
global rep_batchs,created_batchs,Apache_on
if created_batchs==1:
if Apache_on==1:
OriginePath=os.getcwd()
os.chdir(getcwd()+r"\batchs")
thread.start_new_thread(os.system,("magento-uninstaller.bat",))
time.sleep(1)
thread.start_new_thread(os.chdir,(OriginePath,))
else:
self.ErrorApache()
else:
self.ErrorBatch()
evt.Skip()
def AllocMem(self,evt):
global path_magento,allocated_mem,old_mem
if(path_magento!=""):
old_mem=self.MemorySizeEntry.GetValue()
allocated_mem=1
self.MemorySizeEntry.Enable()
self.MemorySizeEntry.SetFocus()
self.MemorySizeEntry.SetSelection(-1,-1)
self.Bind(wx.EVT_TEXT_ENTER,self.BloqueMem,self.MemorySizeEntry)
else:
dlg = wx.MessageDialog(self,u"PATH de MAGENTO NON défini !!!\nVous ne pouvez pas continuer !","Erreur de PATH de MAGENTO !",\
style=wx.ICON_ERROR|wx.STAY_ON_TOP|wx.CENTER|wx.OK) #Definit les attributs de la fenetre de message.
dlg.ShowModal()
evt.Skip()
def BloqueMem(self,evt):
global Val_mem,created_batchs
Val_mem=self.MemorySizeEntry.GetValue()
self.Pick_datas()
self.MemorySizeEntry.Disable()
if(created_batchs==1):
self.UpdateBatchs()
evt.Skip()
def Pick_datas(self):
global path_magento,path_defined,Val_mem,allocated_mem,created_batchs
imp = file(str(rep_conf)+"\\magentools.conf",'w')
pickle.dump((path_defined,path_magento,Val_mem,allocated_mem,created_batchs),imp)
def CreateBatch(self,evt):
global rep_batchs,path_magento,Val_mem,allocated_mem,created_batchs
Val_mem=self.MemorySizeEntry.GetValue()
if(path_magento!=""):
if(allocated_mem==1):
if not exists(rep_batchs+"\\magento-cache-cleaner.bat"):
with open(rep_batchs+"\\magento-cache-cleaner.bat", "w") as batch:
batch.write('@echo off\n')
batch.write('chcp 1252\n')
batch.write('echo ------Nettoie le cache de Magento 2------\n')
batch.write('php '+path_magento+' cache:clean\n')
batch.write('TIMEOUT /t 3 /nobreak\n')
batch.write('echo ------ Flush le cache de Magento 2------\n')
batch.write('echo Cache Nettoyé !\n')
batch.write('echo Le programme se terminera dans 3 secondes...\n')
batch.write('echo Appuyez sur une touche pour quitter tout de suite !\n')
batch.write('TIMEOUT /t 3\n')
batch.write('exit\n')
else:
pass
if not exists(rep_batchs+"\\magento-memory-size-definer.bat"):
with open(rep_batchs+"\\magento-memory-size-definer.bat", "w") as batch:
batch.write('@echo off\n')
batch.write('chcp 1252\n')
batch.write('echo ------Outil de définition de mémoire Magento 2------\n')
batch.write('php -dmemory_limit='+str(Val_mem)+'G '+path_magento+' setup:static-content:deploy\n')
batch.write('echo Nouvelle allocation mémoire définie !\n')
batch.write('echo Le programme se terminera dans 3 secondes...\n')
batch.write('echo Appuyez sur une touche pour quitter tout de suite !\n')
batch.write('TIMEOUT /t 3\n')
batch.write('exit\n')
else:
pass
if not exists(rep_batchs+"\\magento-reindexer.bat"):
with open(rep_batchs+"\\magento-reindexer.bat", "w") as batch:
batch.write('@echo off\n')
batch.write('chcp 1252\n')
batch.write('echo ------Outil de réindexation Magento 2------\n')
batch.write('php '+path_magento+' indexer:reindex\n')
batch.write('echo Réindexation éffectuée !\n')
batch.write('echo Le programme se terminera dans 3 secondes...\n')
batch.write('echo Appuyez sur une touche pour quitter tout de suite !\n')
batch.write('TIMEOUT /t 3\n')
batch.write('exit\n')
else:
pass
if not exists(rep_batchs+"\\magento-uninstaller.bat"):
with open(rep_batchs+"\\magento-uninstaller.bat", "w") as batch:
batch.write('@echo off\n')
batch.write('chcp 1252\n')
batch.write('echo ------Outil de désinstallation de Magento 2------\n')
batch.write('set choix=\n')
batch.write('SET /P choix=Voulez-vous vraiment désinstaller Magento 2 ?(y/n)\n')
batch.write('if /I "%choix%"=="y" goto choix1\n')
batch.write('if /I "%choix%"=="n" goto choix2\n')
batch.write(':choix1\n')
batch.write('php '+path_magento+' setup:uninstall -n\n')
batch.write('echo Désinstallation éffectuée ! \n')
batch.write('echo Le programme se terminera dans 3 secondes...\n')
batch.write('echo Appuyez sur une touche pour quitter tout de suite !\n')
batch.write('TIMEOUT /t 3\n')
batch.write('exit\n')
batch.write(':choix2\n')
batch.write('echo Désinstallation interrompue !\n')
batch.write('echo Le programme se terminera dans 3 secondes...\n')
batch.write('echo Appuyez sur une touche pour quitter tout de suite !\n')
batch.write('TIMEOUT /t 3\n')
batch.write('exit\n')
created_batchs=1
self.Pick_datas()
else:
pass
if(created_batchs==1):
self.txtVideCreateBatch.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ))
self.txtVideCreateBatch.SetForegroundColour(u"sea green")#On peut choisir la couleur(red,white,blue....)
self.txtVideCreateBatch.SetLabel(u"Batchs crées avec succès !")
self.buttonCreateBatch.Disable()
else:
self.txtVideCreateBatch.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ))
self.txtVideCreateBatch.SetForegroundColour(u"red")#On peut choisir la couleur(red,white,blue....)
self.txtVideCreateBatch.SetLabel(u"Erreur lors de la création des BATCHS !")
else:
dlg = wx.MessageDialog(self,u"ALLOCATION mémoire NON définie !!!\nVous ne pouvez pas continuer !",u"Erreur d'allocation mémoire !",\
style=wx.ICON_ERROR|wx.STAY_ON_TOP|wx.CENTER|wx.OK) #Definit les attributs de la fenetre de message.
dlg.ShowModal()
else:
dlg = wx.MessageDialog(self,u"PATH de MAGENTO NON défini !!!\nVous ne pouvez pas continuer !",u"Erreur de PATH de MAGENTO !",\
style=wx.ICON_ERROR|wx.STAY_ON_TOP|wx.CENTER|wx.OK) #Definit les attributs de la fenetre de message.
dlg.ShowModal()
evt.Skip()
def UpdateBatchs(self):
global path_magento,Val_mem,old_mem,rep_batchs,old_path
#Cache Cleaner Update
with open(rep_batchs+"\\magento-cache-cleaner.bat", "r") as batch:
data = batch.readlines()
data[3]=data[3].replace(str(old_path),str(path_magento),1)
with open(rep_batchs+"\\magento-cache-cleaner.bat", "w") as batch:
batch.writelines(data)
#Memory Sizer Update
with open(rep_batchs+"\\magento-memory-size-definer.bat", "r") as batch:
data = batch.readlines()
data[3]=data[3].replace(str(old_mem),str(Val_mem),1)
data[3]=data[3].replace(str(old_path),str(path_magento),1)
with open(rep_batchs+"\\magento-memory-size-definer.bat", "w") as batch:
batch.writelines(data)
#Reindexer Update
with open(rep_batchs+"\\magento-reindexer.bat", "r") as batch:
data = batch.readlines()
data[3]=data[3].replace(str(old_path),str(path_magento),1)
with open(rep_batchs+"\\magento-reindexer.bat", "w") as batch:
batch.writelines(data)
#Uninstaller Update
with open(rep_batchs+"\\magento-uninstaller.bat", "r") as batch:
data = batch.readlines()
data[8]=data[8].replace(str(old_mem),str(Val_mem),1)
with open(rep_batchs+"\\magento-uninstaller.bat", "w") as batch:
batch.writelines(data)
date = time.strftime("%A %d/%m/%Y\n%H:%M:%S")
self.txtVideCreateBatch.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ))
self.txtVideCreateBatch.SetForegroundColour(u"sea green")#On peut choisir la couleur(red,white,blue....)
self.txtVideCreateBatch.SetLabel(u"BATCHS mis à jour !\n"+str(date))
def VerifRep(self):
global rep_batchs,rep_conf
rep_batchs = (getcwd()+"\\batchs")
rep_conf=(getcwd()+"\\config")
#Vérification des répertoires
if exists(rep_batchs): #Verifie que le répertoire "batchs" existe.
pass #Si oui il ne fait rien et continue
else : #Sinon
os.mkdir(rep_batchs) #Crée le repertoire "batchs" s'il n'existe pas.
if exists(rep_conf): #Verifie que le répertoire "config" existe.
pass #Si oui il ne fait rien et continue
else : #Sinon
os.mkdir(rep_conf) #Crée le repertoire "config" s'il n'existe pas.
def Init_vars(self):
global rep_batchs,rep_conf,path_defined,path_magento,Val_mem,allocated_mem,created_batchs,old_mem,old_path,Apache_on
if exists(rep_conf+"\\magentools.conf"):
dep=file(str(rep_conf)+"\\magentools.conf",'r') #Ouvre le fichier "magentools.conf" en lecture
path_defined,path_magento,Val_mem,allocated_mem,created_batchs=pickle.load(dep)
self.MemorySizeEntry.SetValue(int(Val_mem))
self.MemorySizeEntry.Disable()
if(created_batchs==1):
old_mem=Val_mem
old_path=path_magento
self.buttonCreateBatch.Disable()
self.txtVideCreateBatch.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ))
self.txtVideCreateBatch.SetForegroundColour(u"red")#On peut choisir la couleur(red,white,blue....)
self.txtVideCreateBatch.SetLabel(u"BATCHS déjà crées !")
else:
self.MemorySizeEntry.Disable()
created_batchs=0
path_defined=0
allocated_mem=0
path_magento=""
Val_mem=1
imp = file(str(rep_conf)+"\\magentools.conf",'w')
pickle.dump((path_defined,path_magento,Val_mem,allocated_mem,created_batchs),imp)
def AfficheChemin(self):
global path_defined,path_magento
if path_defined==1:
try:
self.txtVideParcourir.SetFont(wx.Font(10, wx.DEFAULT , wx.NORMAL, wx.NORMAL,False, u"Arial" ))
self.txtVideParcourir.SetForegroundColour(u"blue")#On peut choisir la couleur(red,white,blue....)
self.txtVideParcourir.SetLabel(path_magento)
self.txtVideParcourir.Wrap(300)
except:
self.txtVideParcourir.SetLabel("Erreur d'affichage...(Pas grave) ;)")
def Chrono(self):#Chronometre (date et heure)
stemps = time.strftime("%A %d/%m/%Y") #Definit le format voulu
self.SetStatusText(stemps,1) #Affiche a chaque seconde.
def CreerBarreEtat(self):#Creation de la barre d'etat du bas avec l'affichage de l'heure et date
self.CreateStatusBar(2) #Cree une barre de statut (en bas) de deux parties.
self.SetStatusWidths([-1,150]) #Definit la taille.
self.Chrono()#Affiche.
def Parcourir(self,evt):
global path_defined,path_magento,created_batchs,old_path
if path_defined==0:
dlg =wx.FileDialog(self,u"Choisir un fichier",os.getcwd(),"magento",style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
path_magento = dlg.GetPath()
path_defined=1 #Le PATH de MAGENTO à été défini
old_path=path_magento
self.AfficheChemin()
self.Pick_datas()
else:
dlg = wx.MessageDialog(self,u"PATH de MAGENTO déjà défini ! Voulez-vous changer le PATH de MAGENTO ?","Changement de PATH de MAGENTO !",\
style=wx.ICON_EXCLAMATION|wx.STAY_ON_TOP|wx.CENTER|wx.YES_NO|wx.CANCEL) #Definit les attributs de la fenetre de message.
if dlg.ShowModal() == wx.ID_YES:
dlg =wx.FileDialog(self,u"Choisir un fichier",os.getcwd(),"magento",style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
old_path=path_magento
if dlg.ShowModal() == wx.ID_OK:
path_magento = dlg.GetPath()
self.AfficheChemin()
self.Pick_datas()
if(created_batchs==1):
self.UpdateBatchs()
evt.Skip()
def on_close(evt):#Pour kill le timer
wx.EVT_CLOSE(frame, on_close)
self.timer.Stop()
frame.Destroy()
evt.Skip()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, None)
frame.Show(True)
frame.Centre()
return True
if __name__=='__main__':
app = MyApp(0)
app.MainLoop() |
Partager