コード例 #1
0
ファイル: Alerter.py プロジェクト: ennedigi/BinManager
  def menu(self,skipMenu):  

      while True:

        if platform.system() == 'Windows':     
          os.system('cls')
        else: os.system('clear')
        
      
        print '\nBinAlerter \n================================='
        print '\nYou will be alerted if any change occurs in one of the following folders:'
        for i in enumerate(self.filesFolderList):
          print '\n',i[0]+1,' ',
          ColorConsole.printC(i[1][0],'red')

        #Skip the menu
        if skipMenu: return
        
        choice = raw_input('\n\nAre you sure? (y/n) ')
      
        if choice == 'n':

          listOfFolders=[]

          while True:
                
            temp = raw_input('Enter the new (if any): ',)

            if temp == '': break
            elif not os.path.isdir(temp): 
              print ' Error:',temp, ' is not valid.'; time.sleep(2); continue
            else: listOfFolders.append(temp)

            c = raw_input('Yet another folder? (y/n) ')

            if c=='n': break
            elif c=='y': pass
            else: print ' Error: Input not valid.'; time.sleep(2)

          if not listOfFolders: sys.exit(0)
          else:   
            #Like in the constructor
            self.filesFolderList=[]
            for i in listOfFolders:
              self.validateFolder(i)
              self.filesFolderList.append([i,Util.mostRecentFiles(i)])
            break

        elif choice=='y': break
        else: print 'Choice not valid!'; time.sleep(2)
コード例 #2
0
ファイル: PrintUtil.py プロジェクト: ennedigi/BinManager
  def printListOneDir(dir1, n=5):
      
    try:
      list_dir1=Util.mostRecentFiles(dir1)
        
      #STAMPA SOLO I FILE AGGIORNATI 
      print '\n\nThe most recent files in ',
      ColorConsole.printC(dir1,'red')
      print ' are:',
        
      for i in enumerate(list_dir1[:n]):
        print '\n\t{0} {1:35s} {2}'.format(i[0] + 1, os.path.basename(i[1][0]), time.ctime(i[1][1])),
          
    except: print 'Error!'

    return list_dir1
コード例 #3
0
ファイル: Util.py プロジェクト: ennedigi/BinManager
  def setNewValue(obj,nameValue,oldValue,attrbName,checkIsADir=True):

    while True:
      print nameValue,
      ColorConsole.printC(oldValue,'red')
      temp = raw_input('\nEnter the new (if any): ',)

      if checkIsADir: #Sometimes the input is not a folder
        if not os.path.isdir(temp):
          if temp:
            if os.path.isdir(os.path.dirname(temp)):
              os.mkdir(temp)
              break
            else: print ' Error: Input not valid.'; time.sleep(2)
          else: temp=oldValue; break # temp=''

        else: break

      else: temp=oldValue; break

    setattr(obj,attrbName,temp)
コード例 #4
0
ファイル: PrintUtil.py プロジェクト: ennedigi/BinManager
  def printListCompare2(dir1, dir2, n=5):
    
    try:
      list_source=Util.mostRecentFiles(dir1)
      
      list_target=Util.mostRecentFiles(dir2)
      


      #Create dictionaries: filename -> modified date
      d_target={}
      
      if list_target:
        for i in list_target:
          d_target[i[0]]=i[1]
        
      print '\n\nThe most recent files in ',
      ColorConsole.printC(dir1,'red')
      print ' are:',
      
      for i in enumerate(list_source[:n]):

        try:
        
          if i[1][1]!=d_target[i[1][0]]:
          #number - filename - modified data
            print '\n\t{0} {1:35s} '.format(i[0]+1,os.path.basename(i[1][0])),
            ColorConsole.printC(time.ctime(i[1][1]),'green')
            
          else:
            print '\n\t{0} {1:35s} {2}'.format(i[0] + 1,os.path.basename(i[1][0]), time.ctime(i[1][1])),
            
        except KeyError: print '\n\t{0} {1:35s} {2}'.format(i[0] + 1,os.path.basename(i[1][0]), time.ctime(i[1][1])),
      
      
      if list_target!=[]:
        print '\n\nThe most recent files in ',
        ColorConsole.printC(dir2,'red')
        print ' are:',
        
        for i in enumerate(list_target[:n]):     
          print '\n\t{0} {1:35s} {2}'.format(i[0] + 1, os.path.basename(i[1][0]), time.ctime(i[1][1])),
      else: 
        print '\n\n',
        ColorConsole.printC(dir2,'red')
        print 'is empty'

        
    except: print 'Error' #, sys.exc_info()[1]
コード例 #5
0
ファイル: __init__.py プロジェクト: ennedigi/BinManager
  def menu(self):
    try:
      choice = ''
      
      while not choice in ['1', '2', '3', '4','q']:
        
        if choice: print 'Choice not valid!'; time.sleep(2)
            
        ColorConsole.cleanScreen()
              
        print '\nWelcome to ',
        ColorConsole.printC('BinManager','red')
        print VERSION

        print '------------------------------\n'
        print '1) Install the last bin'
        print '2) Zip the last bin'
        print '3) Start Bin Alerter'
        print '4) Prepare the Translation'
        print 'q) Quit\n'

    
        choice = raw_input('Select: ')
        
        
      if choice == '1': Copier(self.dirSource,self.dirTarget).start()
      
      if choice == '2': Zipper(self.dirSource,self.zipTarget).start()
      
      if choice == '3': Alerter(self.dirAlert).run()

      if choice == '4': ToTranslate(self.dirSource,self.dirTarget, self.transDir).start()

      if choice == 'q': sys.exit(0)
  
    except SystemExit: print 'The program has quit';
    except: print sys.exc_info()[1]
コード例 #6
0
ファイル: PrintUtil.py プロジェクト: ennedigi/BinManager
 def printListCompare(dir, list_dir1, list_dir2, n=5):
   
   try:
     #Create dictionaries: filename -> modified date
     d_1={}
         
     for i in list_dir1:
       d_1[i[0]]=i[1]
     
     print '\n\nThe most recent files in ',
     ColorConsole.printC(dir,'red')
     print ' are:',
     
     for i in enumerate(list_dir2[:n]):
       try: 
         if i[1][1]!=d_1[i[1][0]]:
           #number - filename - modified data
           print '\n\t{0} {1:35s} '.format(i[0]+1,os.path.basename(i[1][0])),
           ColorConsole.printC(time.ctime(i[1][1]),'green')
         else:
           print '\n\t{0} {1:35s} {2}'.format(i[0] + 1,os.path.basename(i[1][0]), time.ctime(i[1][1])),
       except: print '\n\t{0} {1:35s} {2}'.format(i[0] + 1,os.path.basename(i[1][0]), time.ctime(i[1][1])),
     
   except: print 'Error',sys.exc_info()[1]
コード例 #7
0
ファイル: Copier.py プロジェクト: ennedigi/BinManager
  def start(self):

    try:
      
      choice = ''
      
      while not choice in ['y','n']:

        if choice: print ' Error: Input not valid.'; time.sleep(2);
        
        #Clean screen
        ColorConsole.cleanScreen()
        
        print '\nBinCopier \n================================='
        print '\nSource: ',
        ColorConsole.printC(self.dirSource,'red')
        print '\nTarget: ',
        ColorConsole.printC(self.dirTarget,'red')
    
        choice = raw_input('\n\nAre you sure? (y/n) ')
  
  #Redefine and the relative messages to print on screen
        if choice == 'n':
          Util.setNewValue(self,'Source: ',self.dirSource,'dirSource')
          Util.setNewValue(self,'Target: ',self.dirTarget,'dirTarget')

          choice = ''

  #Print the list of the most recent
      PrintUtil.printListCompare2(self.dirSource,self.dirTarget)

      choice=''
      
      while not choice in ['1','2']:
        
        if choice: print 'Choice not valid!'; time.sleep(2)
     
        choice = raw_input('\n\n(1) Update the folder \n(2) Replace all the files\n Select [1,2]: ')
  
  #Init the LOG
      self.logInit()
        
      if choice=='1': self.copyFun(self.dirSource,self.dirTarget,'','update')
      if choice=='2': self.copyFun(self.dirSource,self.dirTarget,'','replace')
      
      if not self.n_err and self.n_file: 
        if Copier.x64: self.updateDLLs('register_4.0_x64.bat')
        else: self.updateDLLs()

      self.logClose()

    except SystemExit: pass
    except: print sys.exc_info()[1],'The program has quit'
コード例 #8
0
ファイル: Zipper.py プロジェクト: ennedigi/BinManager
  def start(self):
    
    try:
    
      choice = ''
      
      while not choice == 'y':
        
        if choice: print 'Choice not valid!'; time.sleep(2)

        if platform.system() == 'Windows':     
          os.system('cls')
        else: os.system('clear')

        print '\nBinZipper \n================================='
        print '\nFolder to zip: ',
        ColorConsole.printC(self.folderToZip,'red')
        print '\nThe file: ',
        ColorConsole.printC(self.namefile,'red')
        print '\nwill be created in ',
        ColorConsole.printC(self.target,'red')
        
    
        choice = raw_input('\n\nAre you sure? (y/n) ')
  
        if choice == 'n':

          Util.setNewValue(self,'Folder to zip: ', self.folderToZip,'folderToZip')
          Util.setNewValue(self,'Zip file: ',self.namefile,'namefile',False)
          Util.setNewValue(self,'Destination: ',self.target,'target')

          choice=''


      self.zipBrain()

    except SystemExit: pass
    except: print sys.exc_info()[1],'The program has quit'