scripts/get_traffic.py
def write_referrers_to_file(self, file_path='',
        date=str(datetime.date.today()), organization='llnl'):
        """
        Writes the referrers data to file.
        """
        self.remove_date(file_path=file_path, date=date)
        referrers_exists = os.path.isfile(file_path)
        with open(file_path, 'a') as out:
            if not referrers_exists:
                out.write('date,organization,referrer,count,count_log,uniques,'
                    + 'uniques_logged\n')
            sorted_referrers = sorted(self.referrers_lower)#sort based on lowercase
            for referrer in sorted_referrers:
                ref_name = self.referrers_lower[referrer]#grab real name from
                count = self.referrers[ref_name][0]
                uniques = self.referrers[ref_name][1]
                if count == 1:#so we don't display 0 for count of 1
                    count = 1.5
                if uniques == 1:
                    uniques = 1.5
                count_logged = math.log(count)
                uniques_logged = math.log(uniques)
                out.write(date + ',' + organization + ','
                + ref_name + ',' + str(count) + ',' + str(count_logged) + ','
                + str(uniques) + ',' + str(uniques_logged) + '\n')
        out.close()
def write_referrers_to_file(self, file_path='',
        date=str(datetime.date.today()), organization='llnl'):
        """
        Writes the referrers data to file.
        """
        self.remove_date(file_path=file_path, date=date)
        referrers_exists = os.path.isfile(file_path)
        with open(file_path, 'a') as out:
            if not referrers_exists:
                out.write('date,organization,referrer,count,count_log,uniques,'
                    + 'uniques_logged\n')
            sorted_referrers = sorted(self.referrers_lower)#sort based on lowercase
            for referrer in sorted_referrers:
                ref_name = self.referrers_lower[referrer]#grab real name from
                count = self.referrers[ref_name][0]
                uniques = self.referrers[ref_name][1]
                if count == 1:#so we don't display 0 for count of 1
                    count = 1.5
                if uniques == 1:
                    uniques = 1.5
                count_logged = math.log(count)
                uniques_logged = math.log(uniques)
                out.write(date + ',' + organization + ','
                + ref_name + ',' + str(count) + ',' + str(count_logged) + ','
                + str(uniques) + ',' + str(uniques_logged) + '\n')
        out.close()
def write_referrers_to_file ( self , file_path = '' , date = str ( datetime . date . today ( ) ) , organization = 'llnl' ) : self . remove_date ( file_path = file_path , date = date ) referrers_exists = os . path . isfile ( file_path ) with open ( file_path , 'a' ) as out : if not referrers_exists : out . write ( 'date,organization,referrer,count,count_log,uniques,' + 'uniques_logged\n' ) sorted_referrers = sorted ( self . referrers_lower ) #sort based on lowercase for referrer in sorted_referrers : ref_name = self . referrers_lower [ referrer ] #grab real name from count = self . referrers [ ref_name ] [ 0 ] uniques = self . referrers [ ref_name ] [ 1 ] if count == 1 : #so we don't display 0 for count of 1 count = 1.5 if uniques == 1 : uniques = 1.5 count_logged = math . log ( count ) uniques_logged = math . log ( uniques ) out . write ( date + ',' + organization + ',' + ref_name + ',' + str ( count ) + ',' + str ( count_logged ) + ',' + str ( uniques ) + ',' + str ( uniques_logged ) + '\n' ) out . close ( )
Writes the referrers data to file.
Writes the referrers data to file .