def __init__(self, app): gobject.GObject.__init__(self) self.app = app self.blocks = {} self.wcf_uid_list = [] self.chrono_times = {} self.chrono_day = time.localtime().tm_wday if not os.path.exists(BLOCK_DB): try: os.makedirs(os.path.dirname(BLOCK_DB)) except: pass else: try: db = open(BLOCK_DB, 'rb') p = pickle.load(db) self.blocks = p[0] self.wcf_uid_list = p[1] self.chrono_times = p[2] self.chrono_day = p[3] db.close() except: print "Something wrong unpickling" self.__next_update_info = None self.usersmanager = UsersManager() if os.name == "nt": self.win32top = Win32Top(self) self.chrono = Chrono(self) self.firewall_filter = FirewallFilter(self) self.filter_manager = FilterManager(self) self.webcontent_filter = WebContentFilter(self, app) self.session_filter = SessionFilter(self) gobject.timeout_add(1000, self.__polling_cb)
end_sound = mixer.Sound(END_SOUND) goal_sound = mixer.Sound(GOAL_SOUND) os.environ['SDL_VIDEO_CENTERED'] = '1' icon = pygame.image.load(ICON) pygame.display.set_icon(icon) pygame.display.set_caption(TITLE) screen = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32) bg = pygame.image.load(BG_PATH).convert() bg_instruction = pygame.image.load(BG_INSTRUCTION_PATH).convert() clock = pygame.time.Clock() chrono = Chrono(0, 0, 0) player1 = Mallet(PLAYER1_START, MALLET_MASS, MALLET_RED_PATH, MALLET_MAX_SPEED, MALLET_ACCELERATION, MALLET_FRICTION, 1) player2 = Mallet(PLAYER2_START, MALLET_MASS, MALLET_BLUE_PATH, MALLET_MAX_SPEED, MALLET_ACCELERATION, MALLET_FRICTION, 2) disc = Disc(DISC_START_POS, DISC_START_ANGLE, DISC_START_SPEED, DISC_MASS, DISC_PATH, DISC_MAX_SPEED, DISC_FRICTION) posts = [] posts.append( Goalpost((BORDER_LEFT, GOAL_START), (-1, -1), GOALPOST_MASS, GOALPOST_PATH)) posts.append( Goalpost((BORDER_LEFT, GOAL_END), (-1, 1), GOALPOST_MASS, GOALPOST_PATH))
def __init__(self, app): gobject.GObject.__init__(self) self.app = app self.blocks = {} self.wcf_uid_list = [] self.chore_settings = {} self.chrono_times = {} self.chrono_day = (datetime.today() - datetime.utcfromtimestamp(0)).days if not os.path.exists(BLOCK_DB): try: os.makedirs(os.path.dirname(BLOCK_DB)) except: pass else: try: db = open(BLOCK_DB, 'rb') p = pickle.load(db) self.blocks = p[0] self.chore_settings = p[1] self.wcf_uid_list = p[2] self.chrono_times = p[3] self.chrono_day = p[4] db.close() except: print "Something wrong unpickling, trying older format (2.31.1)..." # old format (2.31.1) support try: db = open(BLOCK_DB, 'rb') p = pickle.load(db) self.blocks = p[0] self.wcf_uid_list = p[1] self.chrono_times = p[2] self.chrono_day = p[3] db.close() except: print "No success, something just went wrong unpickling" # more old format (2.31.1) support for t in self.chrono_times: announced = False for c in self.chrono_times[t]: if len(self.chrono_times[t] [c].items()) == 2: # 2.31.1 had 2 fields if not announced: print 'Old format (2.31.1) support: adding extra fields to user', t announced = True self.chrono_times[t][c]["extra_time"] = 0 self.chrono_times[t][c]["mercy_count"] = 0 self.chrono_times[t][c]["force_close"] = 0 self.chrono_times[t][c]["last_active"] = -1 self.__next_update_info = None self.usersmanager = UsersManager() if os.name == "nt": self.win32top = Win32Top(self) self.chrono = Chrono(self) self.firewall_filter = FirewallFilter(self) self.filter_manager = FilterManager(self) self.chore_manager = ChoreManager(self) self.webcontent_filter = WebContentFilter(self, app) self.session_filter = SessionFilter(self) gobject.timeout_add(1000, self.__polling_cb)