Exemplo n.º 1
0
    def run_backup(self):

        self.__time_stamp = timestamp.TimeStamp()
        self.__build_source_paths_lazy()
        self.__build_target_file_name()
        self.__move_file_to_first_stop()
        self.__move_file_to_destination()
 def partition_range_bins(self):
     ts = timestamp.TimeStamp()
     daysInRange = self.get_days()
     #print daysInRange
     bins = range(
         self.start_timestamp, self.end_timestamp,
         int((self.end_timestamp - self.start_timestamp) / self.file_count))
     #print "bins", bins, "range",self.start_timestamp,self.end_timestamp
     firstItems = [ts.totimestamp(x[0]) for x in self.daysInRange]
     #print "firstItems",firstItems
     digits = np.digitize(firstItems, bins)
     digits[0] = 1
     return digits
 def get_days(self):
     setDays = []
     TD_1DAY = timedelta(days=1)
     TD_1SECOND = timedelta(seconds=1)
     ts = timestamp.TimeStamp()
     s = ts.todate(self.start_timestamp)
     sTS = datetime(s.year, s.month, s.day)
     eTS = ts.todate(self.end_timestamp)
     currentBegin = sTS
     currentEnd = currentBegin + TD_1DAY
     while currentBegin < eTS:
         setDays.append((currentBegin, currentEnd))
         currentBegin = currentBegin + TD_1DAY
         currentEnd = currentBegin + TD_1DAY
     #print "Start dt",sTS, "End dt",eTS, setDays
     return setDays
Exemplo n.º 4
0
def aNewDay():
    import datetime
    import dbstuff as db
    import timestamp as ts
    rightNow = datetime.datetime.now()
    dow = rightNow.weekday()
    if dow == 0:
        filename = 'monday.jpg'
    elif dow == 1:
        filename = 'teusday.jpg'
    elif dow == 2:
        filename = 'odin.jpg'
    elif dow == 3:
        filename = 'lightning.jpg'
    elif dow == 4:
        filename = 'friday.jpg'
    elif dow == 5:
        filename = 'saturday.jpg'
    elif dow == 6:
        filename = 'sunday.jpg'
    else:
        filename = 'wheel.jpg'
    imgTag = '<img src="static/{picname}" width="25%" align="center"/>'
    imgLine = imgTag.format(picname=filename)
    timetag = rightNow.strftime("%A, %b %d, %Y")
    outstr = """
  <h2> Good morning it is {daytag} </h2>
  {pictag}
  """

    myStamp = ts.TimeStamp()
    newDay = myStamp.daypart() + "000000"
    if db.timeNoted(newDay):
        db.removeentry(newDay)
    db.addentry('journal', newDay, outstr.format(daytag=timetag,
                                                 pictag=imgLine), "-----")
 def gen_url(self, start, end):
     ts = timestamp.TimeStamp()
     startDate = ts.todate(start)
     endDate = ts.todate(end)
     print startDate, endDate
                        '--count_files',
                        metavar='N',
                        required='Y',
                        type=str,
                        help='number of files to create')
    parser.add_argument('-s',
                        '--start',
                        metavar='N',
                        required='Y',
                        type=str,
                        help='unix date to start on')
    parser.add_argument('-e',
                        '--end',
                        metavar='N',
                        required='Y',
                        type=str,
                        help='unix date to start on')
    args = parser.parse_args()
    return args


if __name__ == '__main__':
    args = get_args()
    start = datetime.strptime(args.start, "%Y-%m-%d")
    end = datetime.strptime(args.end, "%Y-%m-%d")
    ts = timestamp.TimeStamp()
    a = api_gen(ts.totimestamp(start), ts.totimestamp(end),
                int(args.count_files))
    a.gen_range_sets()
    print args, a.rng, a.oneday, a.dayCount, a.normalDaysInFile