def fetch_show_all(): this.show_all_cfg = tk.IntVar(value=config.get_int("ugc_show_all")) this.show_all = this.show_all_cfg.get() config.set("ugc_show_all", this.show_all) this.show_all_cfg = tk.IntVar(value=config.get_int("ugc_show_all")) fetch_show_all_bgs() return ()
def plugin_start(plugin_dir): this.rseData = RseData(plugin_dir) settings = config.get_int(this.CONFIG_MAIN) or 0 # default setting this.rseData.ignored_projects_flags = config.get_int(this.CONFIG_IGNORED_PROJECTS) this.clipboard = tk.BooleanVar(value=((settings >> 5) & 0x01)) this.overwrite = tk.BooleanVar(value=((settings >> 6) & 0x01)) this.edsmBodyCheck = tk.BooleanVar(value=not ((settings >> 7) & 0x01)) # invert to be on by default this.debug = tk.BooleanVar(value=((settings >> 8) & 0x01)) if this.debug.get(): level = logging.DEBUG logger.setLevel(level) for handler in logger.handlers: handler.setLevel(level) this.enabled = check_transmission_options() this.queue = Queue() this.worker = BackgroundWorker(this.queue, this.rseData) this.worker.name = "EDSM-RSE Background Worker" this.worker.daemon = True this.worker.radiusExponent = RseData.DEFAULT_RADIUS_EXPONENT this.worker.start() logger.debug("Debug messages are enabled.") logger.debug("Python Version: {0}.".format(sys.version)) return RseData.PLUGIN_NAME
def getconfig(): config.set('ugc_wurl', this.wurl_cfg.get().strip()) config.set('ugc_rurl', this.rurl_cfg.get().strip()) config.set('ugc_debug', this.debug_cfg.get()) config.set('ugc_update', this.update_cfg.get()) config.set('ugc_show_all', this.show_all_cfg.get()) config.set('ugc_show_all_bgs', this.show_all_bgs_cfg.get()) config.set('ugc_send_cmdr', this.send_cmdr_cfg.get()) this.rurl = config.get_str("ugc_rurl") this.wurl = config.get_str("ugc_wurl") if config.get_int("ugc_show_all_bgs") == 1: this.show_all_bgs = True else: this.show_all_bgs = False if config.get_int("ugc_debug") == 1: this.debug = True else: this.debug = False if config.get_int("ugc_send_cmdr") == 1: this.send_cmdr = True else: this.send_cmdr = False if config.get_int("ugc_show_all") == 1: this.show_all = True else: this.show_all = False return
def fetch_slow_state(): this.slow_state_cfg = tk.IntVar(value=config.get_int("ugc_slow_state")) this.slow_state_cfg = this.slow_state_cfg.get() config.set("ugc_slow_state", this.slow_state_cfg) this.slow_state_cfg = tk.IntVar(value=config.get_int("ugc_slow_state")) this.slow_state = this.slow_state_cfg.get() if this.slow_state == 1: this.slow_state = True else: this.slow_state = False return
def fetch_debug(): this.debug_cfg = tk.IntVar(value=config.get_int("ugc_debug")) this.debug_cfg = this.debug_cfg.get() config.set("ugc_debug", this.debug_cfg) this.debug_cfg = tk.IntVar(value=config.get_int("ugc_debug")) this.debug = this.debug_cfg.get() if this.debug == 1: this.debug = True else: this.debug = False return (this.debug)
def fetch_show_all_bgs(): first = tk.IntVar(value=config.get_int("ugc_show_all_bgs_first")) first = first.get() if first == 0: config.set("ugc_show_all_bgs_first", 1) config.set("ugc_show_all_bgs", 0) this.show_all_bgs_cfg = tk.IntVar(value=config.get_int("ugc_show_all_bgs")) this.show_all_bgs = this.show_all_bgs_cfg.get() if this.show_all_bgs == 1: this.show_all_bgs = True else: this.show_all_bgs = False return ()
def fetch_send_cmdr(): this.send_cmdr_cfg = tk.IntVar(value=config.get_int("ugc_send_cmdr_first")) this.send_cmdr = this.send_cmdr_cfg.get() if this.send_cmdr == 0: config.set("ugc_send_cmdr_first", 1) config.set("ugc_send_cmdr", 1) this.send_cmdr_cfg = tk.IntVar(value=config.get_int("ugc_send_cmdr")) this.send_cmdr = this.send_cmdr_cfg.get() if this.send_cmdr == 1: this.send_cmdr = True else: this.send_cmdr = False return ()
def plugin_app(parent): """ Create a TK widget for the EDMC main window """ plugin_app.wafer_module_classes = [ ['Surface navigation', SurfaceNavigation], ['Neutron navigation', NeutronNavigation], ['Fleet', FleetMonitor], ['Chat', ChatViewer], ['Long range scanner', FSDTarget], ['Materials helper', MatsHelper], ] plugin_app.wafer_modules = {} plugin_app.frame = FakeNotebook(parent, text='L3-37') plugin_app.theme = config.get_int('theme') plugin_app.fg = config.get_str( 'dark_text') if plugin_app.theme else 'black' plugin_app.hl = config.get_str( 'dark_highlight') if plugin_app.theme else 'blue' plugin_app.bg = 'grey4' if plugin_app.theme else None for module in plugin_app.wafer_module_classes: plugin_app.wafer_modules[module[0]] = module[1]( plugin_app.frame, highlightbackground=plugin_app.fg, highlightcolor=plugin_app.fg, highlightthickness=1) #, relief = tk.SUNKEN, borderwidth = 1) plugin_app.frame.add(plugin_app.wafer_modules[module[0]], module[0]) print("L3-37 loaded") return (plugin_app.frame)
def update_presence(): presence = DiscordRichPresence() if config.get_int("disable_presence") == 0: presence.state = this.presence_state presence.details = this.presence_details presence.startTimestamp = int(this.time_start) Discord_UpdatePresence(presence)
def __init__(self): """init variables""" #init log log_name = config.get_string("Log", "log_name", "gevent") log_level = config.get_string("Log", "log_level", "debug") init_log(log_path=CUR_PATH + "/../log", log_name=log_name, log_level=log_level) self.recv_timeout = config.get_int("Server", "recv_timeout", 10) #init redis connection redis_ip_str = config.get_string("Redis", "ip") redis_port_str = config.get_string("Redis", "port") redis_ip_list = redis_ip_str.split(',') redis_ip_list = [ip.strip() for ip in redis_ip_list] redis_port_list = redis_port_str.split(',') redis_port_list = [int(port.strip()) for port in redis_port_list] self.redis_conn_list = [] for i in xrange(len(redis_ip_list)): redis_conn = redis.StrictRedis(host=redis_ip_list[i], port=redis_port_list[i], db=0) self.redis_conn_list.append(redis_conn)
def plugin_prefs(parent, cmdr, is_beta): """ Return a TK Frame for adding to the EDMC settings dialog. """ if isinstance(appversion, str): core_version = semantic_version.Version(appversion) elif callable(appversion): core_version = appversion() logger.info(f'Core EDMC version: {core_version}') if core_version < semantic_version.Version('5.0.0-beta1'): logger.info('EDMC core version is before 5.0.0-beta1') this.disablePresence = tk.IntVar( value=config.getint("disable_presence")) else: logger.info('EDMC core version is at least 5.0.0-beta1') this.disablePresence = tk.IntVar( value=config.get_int("disable_presence")) frame = nb.Frame(parent) nb.Checkbutton(frame, text="Disable Presence", variable=this.disablePresence).grid() nb.Label(frame, text='Version %s' % VERSION).grid(padx=10, pady=10, sticky=tk.W) return frame
def fetch_update(): this.update_cfg = tk.IntVar(value=config.get_int("ugc_update_first")) this.update = this.update_cfg.get() if this.update == 0: if this.debug: this.log.debug("Updating") config.set("ugc_update_first", 1) config.set("ugc_update", 1) plugin_update() this.update_cfg = tk.IntVar(value=config.get_int("ugc_update")) this.update = this.update_cfg.get() if this.update == 1: this.update = True else: this.update = False return (this.update)
def get_settings_travelled(): settings = config.get_int("DistanceCalc_options") setting_total = settings & 1 # calculate total distance travelled setting_session = (settings >> 1) & 1 # calculate for session only setting_session_option = ( settings >> 2 ) & 1 # 1 = calculate for ED session; 0 = calculate for EDMC session return setting_total, setting_session, setting_session_option
def loadConfigVars(): this.includePlanetary = tk.IntVar( value=config.get_int("Route-Tracker_includePlanetary", default=1)) this.minSupplyInt = tk.DoubleVar( value=config.get_str("Route-Tracker_MinSupply", default=1.5)) this.hopDistInt = tk.IntVar( value=config.get_int("Route-Tracker_hopDist", default=0)) this.priceAgeInt = tk.IntVar( value=config.get_int("Route-Tracker_priceAge", default=30)) this.minDemandInt = tk.IntVar( value=config.get_int("Route-Tracker_minDemand", default=0)) this.minProfitInt = tk.IntVar( value=config.get_int("Route-Tracker_minProfit", default=20000)) this.currentSystem = config.get_str("Route-Tracker_CurrentSystem", default='Sol') this.currentStation = config.get_str("Route-Tracker_CurrentStation", default="Abraham Lincoln")
def __init__(self, parent, *args, **options): WaferModule.__init__(self, parent, *args, **options) """ Create a TK widget for the EDMC main window """ self.theme = config.get_int('theme') self.fg = config.get_str('dark_text') if self.theme else 'black' self.hl = config.get_str('dark_highlight') if self.theme else 'blue' self.bg = 'grey4' if self.theme else None self.status = tk.Text(self, bg=self.bg) self.chatcopy = tk.Button(self, text="Copy", command=self.copy_button3) self.chatcopy.grid(row=1, column=0, columnspan=4) self.status['width'] = 1 self.status.grid(row=0, column=0, columnspan=3, sticky='nswe') for i in range(3): self.grid_columnconfigure(i, weight=1) self.status.config(height=10, wrap='word') self.status.see(tk.END) self.status.bind('<Button-3>', lambda e, w='textwidget': self.on_click(e, w)) self.status.bind('Control-x', self.copy_button3) self.status.tag_config('link', underline=1, foreground=self.hl) self.status.tag_config('regular_text', foreground=self.fg) self.status.tag_bind('link', '<Button-1>', showLink) self.status.tag_bind('link', '<Button-3>', lambda e, w='link': on_tag_click(e, w)) self.status.tag_config('systemlink', underline=1, foreground=self.hl) self.status.tag_bind('systemlink', '<Button-1>', showSystem) self.status.tag_bind('systemlink', '<Button-3>', lambda e, w='systemlink': on_tag_click(e, w)) self.status.tag_config('cmdrlink', underline=1, foreground=self.hl) self.status.tag_bind('cmdrlink', '<Button-1>', showCmdr) self.freeze = tk.IntVar(self) self.freezebutton = tk.Checkbutton(self, text="Freeze", variable=self.freeze, fg=self.fg) self.freezebutton.grid(row=2, column=0, columnspan=4) self.scroll = tk.Scrollbar(self, command=self.status.yview) self.scroll.grid(row=0, column=4, sticky='nsew') self.status['yscrollcommand'] = self.scroll.set self.systemMenu = tk.Menu(self, tearoff=0) self.systemMenu.add_command(label="Copy system name", command=copySystem) # self.systemMenu.add_command(label="Copy EDSM link", command = copySystemLink) self.menu = tk.Menu(self, tearoff=0) self.menu.add_command(label="Copy text (Ctrl x)", command=self.copy_button3) self.linkMenu = tk.Menu(self, tearoff=0) self.linkMenu.add_command(label="Copy link", command=copyLink) self.status.insert(tk.END, "Chat viewer loaded", 'regular_text') self.status.config(state=tk.DISABLED) print("Chat Viewer loaded")
def __init__(self): ##init log log_name = config.get_string("Log", "log_name", "gevent") log_level = config.get_string("Log", "log_level", "debug") init_log(log_path=CUR_PATH + "/../log", log_name=log_name, log_level=log_level) redis_ip = config.get_string("Server", "redis_ip") redis_port = config.get_int("Server", "redis_port") redis_p = redis.ConnectionPool(host=redis_ip, port=redis_port, db=0) self.conn = redis.StrictRedis(connection_pool=redis_p)
def get_context_data(self, **kwargs): now = timezone.localtime(timezone.now()) kwargs["innerHtml"] = render_to_string( "publicity/embed_upcoming.html", { "upcoming": get_events( performance__gte=now, performance__lte=now + datetime.timedelta(days=config.get_int( "upcoming_performances_future_days", 14)) ), "site_url": settings.SITE_URL, }).replace("\n", "") return super().get_context_data(**kwargs)
def display(): global lblExplorer global statusExplorer if (config.get_int("showExplorer") != 1): lblExplorer.grid_remove() statusExplorer.grid_remove() else: lblExplorer.grid(row=0, column=0, sticky=tk.W) statusExplorer.grid(row=1, column=0, sticky=tk.W) global lblMerchant global statusMerchant if (config.get_int("showMerchant") != 1): lblMerchant.grid_remove() statusMerchant.grid_remove() else: lblMerchant.grid(row=2, column=0, sticky=tk.W) statusMerchant.grid(row=3, column=0, sticky=tk.W) global lblCombat if (config.get_int("showCombat") != 1): lblCombat.grid_remove() else: lblCombat.grid(row=4, column=0, sticky=tk.W) global lblExo global statusExo if (config.get_int("showExo") != 1): lblExo.grid_remove() statusMerchant.grid_remove() else: lblExo.grid(row=0, column=1, sticky=tk.W) statusExo.grid(row=1, column=1, sticky=tk.W) global lblMerc # global statusMerc if (config.get_int("showMerc") != 1): lblMerc.grid_remove() # statusMerc.grid_remove() else: lblMerc.grid(row=2, column=1, sticky=tk.W) # statusMerc.grid(row=3, column=1, sticky=tk.W) global lblEmpire if (config.get_int("showEmpire") != 1): lblEmpire.grid_remove() else: lblEmpire.grid(row=0, column=2, sticky=tk.W) global lblFederation if (config.get_int("showFederation") != 1): lblFederation.grid_remove() else: lblFederation.grid(row=1, column=2, sticky=tk.W)
def plugin_prefs(parent, cmdr, is_beta): """ Return a TK Frame for adding to the EDMC settings dialog. """ this.disablePresence = tk.IntVar(value=config.get_int("disable_presence")) frame = nb.Frame(parent) nb.Checkbutton(frame, text="Disable Presence", variable=this.disablePresence).grid() nb.Label(frame, text='Version %s' % VERSION).grid(padx=10, pady=10, sticky=tk.W) return frame
def plugin_start(plugin_dir): """ Load this plugin into EDMC """ this.Dir = plugin_dir file = os.path.join(this.Dir, "Today Data.txt") if path.exists(file): with open(file) as json_file: this.TodayData = json.load(json_file) z = len(this.TodayData) for i in range(1, z + 1): x = str(i) this.TodayData[i] = this.TodayData[x] del this.TodayData[x] file = os.path.join(this.Dir, "Yesterday Data.txt") if path.exists(file): with open(file) as json_file: this.YesterdayData = json.load(json_file) z = len(this.YesterdayData) for i in range(1, z + 1): x = str(i) this.YesterdayData[i] = this.YesterdayData[x] del this.YesterdayData[x] file = os.path.join(this.Dir, "MissionLog.txt") if path.exists(file): with open(file) as json_file: this.MissionLog = json.load(json_file) this.LastTick = tk.StringVar(value=config.get_str("XLastTick")) this.TickTime = tk.StringVar(value=config.get_str("XTickTime")) this.Status = tk.StringVar(value=config.get_str("XStatus")) this.DataIndex = tk.IntVar(value=config.get_int("xIndex")) this.StationFaction = tk.StringVar(value=config.get_str("XStation")) response = requests.get( 'https://api.github.com/repos/tezw21/BGS-Tally/releases/latest' ) # check latest version latest = response.json() this.GitVersion = latest['tag_name'] # tick check and counter reset response = requests.get('https://elitebgs.app/api/ebgs/v5/ticks' ) # get current tick and reset if changed tick = response.json() this.CurrentTick = tick[0]['_id'] this.TickTime = tick[0]['time'] if this.LastTick.get() != this.CurrentTick: this.LastTick.set(this.CurrentTick) this.YesterdayData = this.TodayData this.TodayData = {} return "BGS Tally v2"
def __init__(self): distances = json.loads(config.get_str("DistanceCalc") or "[]") self.distances = distances[:this.NUMBER_OF_SYSTEMS] self.coordinates: Union[Tuple[float, float, float], None] = None self.distance_total: float = float( config.get_int("DistanceCalc_travelled") or 0) / 1000.0 self.distance_session: float = 0.0 a, b, c = self.get_settings_travelled() self.travelled_total_option: tk.IntVar = tk.IntVar(value=a and 1) self.travelled_session_option: tk.IntVar = tk.IntVar(value=b and 1) self.travelled_session_selected: tk.IntVar = tk.IntVar(value=c and 1) self.error_label: Union[tk.Label, None] = None self.settings_ui_elements: List[SettingsUiElements] = list() self.distance_labels: List[Tuple[tk.Label, tk.Label]] = list() self.travelled_labels: List[tk.Label] = list() self.empty_frame: Union[tk.Frame, None] = None self.update_notification_label: Union[HyperlinkLabel, None] = None self.prefs_frame: Union[tk.Frame, None] = None
def __init__(self, parent, *args, **options): WaferModule.__init__(self, parent, *args, **options) self.theme = config.get_int('theme') self.fg = config.get_str('dark_text') if self.theme else 'black' self.hl = config.get_str('dark_highlight') if self.theme else 'blue' self.bg = 'grey4' if self.theme else None self.ships = {} self.bigjsonships = {} self.DeadShip = None self.ship_widgets = {} try: with open(path.join(plugin_path, 'ships.json')) as json_data: self.bigjsonships = json.load(json_data) except: pass self.ships_scroll = VerticalScrolledFrame(self, bg=self.bg) self.ships_scroll.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.last_market_id = None
def update_presence(): if isinstance(appversion, str): core_version = semantic_version.Version(appversion) elif callable(appversion): core_version = appversion() logger.info(f'Core EDMC version: {core_version}') if core_version < semantic_version.Version('5.0.0-beta1'): logger.info('EDMC core version is before 5.0.0-beta1') if config.getint("disable_presence") == 0: this.activity.state = this.presence_state this.activity.details = this.presence_details else: logger.info('EDMC core version is at least 5.0.0-beta1') if config.get_int("disable_presence") == 0: this.activity.state = this.presence_state this.activity.details = this.presence_details this.activity.timestamps.start = int(this.time_start) this.activity_manager.update_activity(this.activity, callback)
def get_context_data(self, **kwargs): now = timezone.localtime(timezone.now()) if self.request.GET.get("embed"): kwargs["BT_extra_body_class"] = "embedded" kwargs["embed"] = self.request.GET.get("embed", False) kwargs["year"] = year = self.kwargs.get("year", now.year) kwargs["month"] = month = self.kwargs.get("month", now.month) date = datetime.date(year, month, 1) kwargs["prev"] = date - datetime.timedelta(days=1) kwargs["next"] = date + datetime.timedelta(days=31) kwargs["month_name"] = calendar.month_name[month] kwargs["calendar"] = calendar kwargs["cal"] = map(lambda dates: [ (date, get_events(performance__date=date)) for date in dates ], generic_calendar.monthdatescalendar(year, month)) kwargs["upcoming"] = get_events( performance__gte=now, performance__lte=now + datetime.timedelta( days=config.get_int("upcoming_performances_future_days", 14))) return super().get_context_data(**kwargs)
def plugin_start3(plugin_dir: str) -> str: """ Load this plugin into EDMC """ global showExplorer showExplorer = tk.IntVar(value=config.get_int("showExplorer")) global showMerchant showMerchant = tk.IntVar(value=config.get_int("showMerchant")) global showCombat showCombat = tk.IntVar(value=config.get_int("showCombat")) global showExo showExo = tk.IntVar(value=config.get_int("showExo")) global showMerc showMerc = tk.IntVar(value=config.get_int("showMerc")) global showEmpire showEmpire = tk.IntVar(value=config.get_int("showEmpire")) global showFederation showFederation = tk.IntVar(value=config.get_int("showFederation")) return "edmc-rank"
def current_season(): return "{} {}".format( Season.SEASONS[config.get_int(settings.ACTIVE_SEASON_KEY, 0)][1], config.get(settings.ACTIVE_YEAR_KEY, ""))
def plugin_start3(plugin_dir): logger.debug("Plugin_start function") """ Load this plugin into EDMC """ this.Dir = plugin_dir # Set up the localDB con = sqlite3.connect(this.Dir + "\\bgs_tally.db") cur = con.cursor() try: systems_table = """ create table if not exists systems ( systemaddress integer PRIMARY KEY, starsystem text NOT NULL )""" cur.execute(systems_table) con.commit() except Error as e: logger.error("Processing DB and table creation") logger.error("Error reported: " + str(e)) con.commit() con.close() try: this.cred = os.path.join(this.Dir, "client_secret.json") except FileNotFoundError: logger.error("missing client secret file for gspread") file = os.path.join(this.Dir, "Today_Data.json") if path.exists(file): with open(file) as json_file: this.TodayData = json.load(json_file) z = len(this.TodayData) for i in range(1, z + 1): x = str(i) this.TodayData[i] = this.TodayData[x] del this.TodayData[x] file = os.path.join(this.Dir, "Yesterday_Data.json") if path.exists(file): with open(file) as json_file: this.YesterdayData = json.load(json_file) z = len(this.YesterdayData) for i in range(1, z + 1): x = str(i) this.YesterdayData[i] = this.YesterdayData[x] del this.YesterdayData[x] this.LastTick = tk.StringVar(value=config.get_str("XLastTick")) this.TickTime = tk.StringVar(value=config.get_str("XTickTime")) this.Status = tk.StringVar(value=config.get_str("XStatus")) this.DataIndex = tk.IntVar(value=config.get_int("xIndex")) this.StationFaction = tk.StringVar(value=config.get_str("XStation")) check_tick() # create google sheet Google_sheet_int() return "BGS Tally v3"
def complete(self): return (self.poster and self.program and self.productionphoto_set.count() >= config.get_int("archive_min_photos", 0))
#write the pid file pid_file = config.get_string("Server", "pid_file", CUR_PATH + "/../run/gevent.pid") fd = open(pid_file, 'a') pid = os.getpid() fd.write("%d\n" % pid) fd.close() def serve_forever(server): put_pid_file() server.serve_forever() #get configuration server_ip = config.get_string("Server", "ip_addr", "0.0.0.0") server_port = config.get_int("Server", "port", 23620) pool_size = config.get_int("Server", "processor_pool_size", 4) processor = Processor() pool = pool.Pool(pool_size) server = DatagramServer((server_ip, server_port), processor, spawn=pool) #server.max_accpet = 10000 server.start() process_count = config.get_int("Server", "processor") #for i in range(process_count - 1): # Process(target=serve_forever, args=(server,)).start() serve_forever(server)
import tkinter.messagebox as tkMessageBox from urllib.parse import urlparse from special_frames import * from web_handlers import * from wafer_module import WaferModule plugin_path = path.join(config.plugin_dir, "edmc-L3-37") with open(path.join(plugin_path, 'flat_ships.json')) as json_data: FLAT_SHIPS = json.load(json_data) theme = config.get_int('theme') theme_fg = config.get_str('dark_text') if theme else 'black' theme_hl = config.get_str('dark_highlight') if theme else 'blue' theme_bg = 'grey4' if theme else None def getclipboard(): r = tk.Tk() clip_text = r.clipboard_get() r.destroy() return (clip_text) def setclipboard(text): r = tk.Tk() r.clipboard_clear()