Exemplo n.º 1
0
 def get_last_data_time (self):
     """
     gets the last timestamp from a logger .dat file
     
     pre:
         self.url should exist. 
     postconditions:
         self.last_data_time is a datetime
     """
     if self.last_data_time == None:
         #~ print self.url[:self.url.find(':')]
         if self.url[:self.url.find(':')] == "http"  or \
            self.url[:self.url.find(':')] == "https" or \
            self.url[:self.url.find(':')] == "ftp" : 
             
             FD = FileDownloader(self.url)
             FD.download()
             data = FD.data
         else: 
             data = open(self.url, 'r').read()
         current_date = data.replace('\r',' ').\
                                split('\n')[-1].split(',')[0]
         if current_date == "" :
             current_date = data.replace('\r',' ').\
                             split('\n')[-2].split(',')[0]
         self.last_data_time = datetime.strptime(current_date, 
                                                 self.date_format) 
     return self.last_data_time
Exemplo n.º 2
0
    def main (self):
        """
        main body of utiliy.

        Preconditions:
        utility setup
            Postconditions:
            utility is run
        """
        download = FileDownloader(self.commands["--url"])
        download.download()
        print download.size
        print download.seconds
        print str(download.rate) + " Mbps"
        print str(download.Bps) + " Bps"