Commits

FredGan committed 0b3181a

Moth copy

Comments (0)

Files changed (3)

     #Create logg objects
     logging.basicConfig(filename=archivepath+'logs'+'_'+date+'.log',format='%(asctime)s %(message)s',level=logging.DEBUG)
     body=''
+    year = int(datetime.now().strftime('%Y'))	
+    moth = int(datetime.now().strftime('%m'))	
+    day = int(datetime.now().strftime('%d'))	
+    l_day = modules.ListDayArch(year,moth)
     for i in paths:
-          if modules.Folderempty(str(i))=='non_empty':
+          if modules.Folderempty('/mnt/'+str(i))=='non_empty':
              logging.info('Start task: '+str(i))
-             archname=archivepath+str(i)+'_'+date+".tar"
+             #Is  last task of the month?
+	     if day ==  max(l_day):
+                  archname=archivepath+str(i)+'_'+date+" mothcopy "+".tar" 	
+             else:
+                  archname=archivepath+str(i)+'_'+date+".tar"
              tar = tarfile.open(archname, "w")
              for root, dir, files in os.walk(str(paths[i])):
                  for file in files:
 from email.mime.text import MIMEText
 import os,re, datetime
 from datetime import date
+import calendar
 #Sending email
 def Sendemail(fro_m,to,subject,body):
     msg = MIMEText(body)
              return state[0]
         else:
              return state[1]
+
+#List of day archives.
+def ListDayArch(year,month):
+    day_arch=(0,2,4)	
+    l_day=[]
+    mday=calendar.monthrange(year, month)
+    for i in range(1,mday[1]):
+        if calendar.weekday(year,month,i) in day_arch:
+           l_day.append(i)
+    return l_day 
 <?xml version="1.1" encoding="UTF-8"?>
     <content>
-           <path tendo = "/mnt/tds"></path>
-           <path domain = "/mnt/domain"></path>
-           <path shuka = "/mnt/shuka"></path>
-           <path kadri = "/mnt/kadri"></path>
-           <path fileserver = "/mnt/fileserver"></path>
-           <path it = "/mnt/it"></path>
            <path hoz_dog = "/mnt/hoz_dog"></path>
            <path com_dog = "/mnt/com_dog"></path>
     </content>