def initializeLock(l): """ :param l: Lock :return: """ # Lock needs to be global for it to be passed to map global lock lock = l if __name__ == '__main__': # Load the configuration config = Parser().parse_config('config/config.conf', 'AWS') # Get only the files with a timestamp of today # Split the files into smaller files, each one containing no more than 500,000 json lines directory = '{0}*.gz'.format(config['flat_data']) file_names = glob.glob(directory) today_files = [] today = datetime.datetime.now() for file_name in file_names: file_date = datetime.datetime.fromtimestamp( os.path.getmtime(file_name)) if file_date.day == today.day and file_date.month == today.month and file_date.year == today.year: today_files.append(file_name)
from socket import * import time from config_parser import Parser class TimeServer: def __init__(self, deception): self.addr = ('localhost', 123) self.socket = socket(AF_INET, SOCK_DGRAM) self.deception = deception def run(self): self.socket.bind(self.addr) while True: print('wait data...') conn, addr = self.socket.recvfrom(1024) print(bytes.decode(conn)) print('client addr: ', addr) self.socket.sendto( str.encode(time.ctime(time.time() + self.deception)), addr) if __name__ == '__main__': conf_parser = Parser() deception = conf_parser.get_deception("settings.ini") time_server = TimeServer(deception) time_server.run()