def timestamp(self): """ Non-static timestamp that changes based on the user's defined timezone """ from util import Clock clock = Clock() return (clock.from_time(self.time).strftime('%Y-%m-%d %H:%M:%S'))
def can_process_event(event, scenario=False): # check if we should wait until daytime to process clock = Clock() sc = SC() if (clock.nighttime() is True) and (scenario is False): if event.magnitude < sc.night_eq_mag_cutoff: return False return True
# python psync.py source dest if __name__ == "__main__": source_root, dest_root = sys.argv[1:] # TODO: What else can we use for peerids when there are no peers? source_peerid = source_root dest_peerid = dest_root # TODO: implement reading .psync. source_groupids = Groupids({"": source_root}) dest_groupids = Groupids({"": dest_root}) conf = Config() clock = Clock() slog = StatusLog(clock) fs = FileSystem(slog) source_db_path = os.path.join(source_root, conf.db_path) dest_db_path = os.path.join(dest_root, conf.db_path) revisions_root = os.path.join(dest_root, conf.revisions_path) fs.create_parent_dirs(source_db_path) fs.create_parent_dirs(dest_db_path) with sqlite3.connect(source_db_path) as source_db: with sqlite3.connect(dest_db_path) as dest_db: source_history_store = HistoryStore(SqlDb(source_db), slog) dest_history_store = HistoryStore(SqlDb(dest_db), slog) revisions = RevisionStore(fs, revisions_root) merge_log = MergeLog(SqlDb(source_db), clock)