Exemple #1
0
 def update_ship(self, ship_data, cmdr):
     self.cmdr = cmdr
     self.ship_data = ship_data
     if 'shipName' in ship_data:
         self.ship_lbl_txt = u"{} ({})".format(
             ship_data['shipName'], ship_map[ship_data['name'].lower()])
     else:
         self.ship_lbl_txt = ship_map[ship_data['name'].lower()]
     self.sysname = ship_data['starsystem']['name']
     self.stationname = ship_data['station']['name']
     try:
         self.market_id = ship_data['station']['id']
     except:
         self.market_id = None
     self.sys_url = get_system_url(self.sysname)
     self.station_url = get_station_url(self.sysname, self.stationname,
                                        None, self.market_id)
     self.system_link.set_system(self.sysname)
     self.station_link.set_station(self.sysname, self.stationname,
                                   self.market_id)
     edID = FLAT_SHIPS[self.ship_data['name'].lower()]['edID']
     if config.get_str('L3_shipyard_provider') == 'Inara':
         self.ship_url = ship_data["shipInaraURL"]
     else:
         self.ship_url = "https://www.edsm.net/en/user/fleet/id/{}/cmdr/{}/ship/sId/{}/sType/{}".format(
             config.get_str('EDSM_id'), urllib.parse.quote_plus(self.cmdr),
             self.ship_data['id'], edID)
     # https://inara.cz/cmdr-fleet/
     self.ship_link.configure(url=self.ship_url, text=self.ship_lbl_txt)
Exemple #2
0
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)
Exemple #3
0
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
Exemple #4
0
def prefs_changed(cmdr, is_beta):
    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.verify_token = this.vtk_cfg.get().strip()
    this.rurl = config.get_str("ugc_rurl")
    this.wurl = config.get_str("ugc_wurl")
    fetch_debug()
    fetch_send_cmdr()
    fetch_slow_state()
    this.paras = {
        'Content-type': 'application/json',
        'Accept': 'text/plain',
        'version': this.__VERSION__,
        "br": this.__MINOR__,
        "branch": this.__BRANCH__,
        "cmdr": str(this.send_cmdr),
        "uuid": this.UUID,
        "token": this.Hash,
        "onlyBGS": str(this.show_all_bgs)
    }
    fetch_show_all()
    #this.sys_state_Thread.run()
    updateMainUi(tick_color="white", systems_color="green")
Exemple #5
0
def cmdr_data(data, is_beta):
    if data.get('commander') is None or data['commander'].get('name') is None:
        raise ValueError("this isn't possible")
    CMDr = data['commander']['name']
    if not config.get_str("ugc_cmdr"):
        config.set("ugc_cmdr", CMDr.encode("ascii", "replace").decode())
        this.CMDr = config.get_str("ugc_cmdr")
        crypter()
Exemple #6
0
 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")
Exemple #7
0
def get_system_url(system_name, provider=None):
    if not provider:
        provider = config.get_str('L3_system_provider')
        if provider == 'none':
            provider = config.get_str('system_provider')
    if provider == 'eddb':
        return ('https://eddb.io/system/name/' +
                urllib.parse.quote_plus(system_name))
    elif provider == 'Inara':
        return ('https://inara.cz/galaxy-starsystem/?search=' +
                urllib.parse.quote_plus(system_name))
    else:
        return ('https://www.edsm.net/show-system?systemName=' +
                urllib.parse.quote_plus(system_name))
Exemple #8
0
def plugin_start3(plugin_dir: str) -> str:
    if not config.get_list(CONFIG_CMDRS):
        # Migrate from single setting
        if config.get_str("FCMSEmail"):
            # first commander will get the old settings
            # CONFIG_CMDR_NAMES set in get_credentials when CMDR name known
            config.set(CONFIG_EMAIL, [config.get_str("FCMSEmail") or ""])
            config.set(CONFIG_API_KEYS, [config.get_str("FCMSKey") or ""])
            config.delete("FCMSEmail")
            config.delete("FCMSKey")
    elif not config.get_list(CONFIG_CMDR_NAMES):
        # Default the FCMS CMDR names to in-game CMDR names
        config.set(CONFIG_CMDR_NAMES, config.get_list(CONFIG_CMDRS))

    return this.plugin_name
Exemple #9
0
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"
Exemple #10
0
def crypter():
    if not this.hwID:
        this.hwID = this.Crypt.ghwid()
    if not this.UUID:
        this.UUID = str(this.Crypt.muuid(this.CMDr,
                                         this.hwID)).replace("'", "|")
    if not config.get_str("ugc_token"):
        config.set("ugc_token", this.Crypt.sign(this.CMDr, this.hwID))
        this.Hash = config.get_str("ugc_token")
    else:
        this.Hash = config.get_str("ugc_token")
    if this.debug:
        this.log.info(this.CMDr)
        this.log.info(this.UUID)
        this.log.info(this.Hash)
    if not this.Crypt.verify(this.CMDr, this.Hash):
        this.Hash = this.Crypt.sign(this.CMDr, this.hwID)
Exemple #11
0
 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
Exemple #12
0
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")
Exemple #13
0
def get_station_url(system_name, station_name, provider=None, market_id=None):
    if not provider:
        provider = config.get_str('L3_station_provider')
        if provider == 'none':
            provider = config.get_str('station_provider')
    if provider == 'eddb':
        if market_id:
            return ('https://eddb.io/station/market-id/' +
                    urllib.parse.quote_plus(str(market_id)))
        else:
            return (get_system_url(system_name, provider='eddb'))
    elif provider == 'Inara':
        return ('https://inara.cz/galaxy-station/?search={}%20[{}]'.format(
            urllib.parse.quote_plus(system_name),
            urllib.parse.quote_plus(station_name)))
    else:
        return ('https://www.edsm.net/show-system?systemName={}&stationName={}'
                .format(urllib.parse.quote_plus(system_name),
                        urllib.parse.quote_plus(station_name)))
Exemple #14
0
 def load(self):
     """
     Load saved distance from config
     :return:
     """
     saved = config.get_str(CFG_DISTANCE)
     if not saved:
         self.saved_distance = 0.0
     else:
         self.saved_distance = float(saved)
Exemple #15
0
def plugin_start(plugin_dir):
    """
    Load Screenshot plugin into EDMC
    """
    this.bmp_loc = tk.StringVar(value=config.get_str("BMP"))
    this.png_loc = tk.StringVar(value=config.get_str("PNG"))
    this.delete_org = tk.StringVar(value=config.get_str("DelOrg"))
    this.mkdir = tk.StringVar(value=config.get_str("Mkdir"))
    this.hideui = tk.StringVar(value=config.get_str("HideUI"))
    this.timer = tk.StringVar(value=config.get_str("Timer"))
    this.scanshot = tk.StringVar(value=config.get_str("Scanshot"))
    this.vdebug = tk.StringVar(value=config.get_str("Debug"))
    this.gamemode = "None"
    if config.get_str("Mask"):
        this.mask = tk.StringVar(value=config.get_str("Mask"))
    else:
        this.mask = tk.StringVar(value="SYSTEM(BODY)_NNNNN.png")

    debug("plugin_start" + this.mask.get())
    checkVersion()

    debug("plugin_start")
    return "Screenshot"
Exemple #16
0
    def _load_route(self, event=None):
        if len(self._route) > 0:
            return

        ftypes = [
            ('All supported files', '*.csv *.txt'),
            ('CSV files', '*.csv'),
            ('Text files', '*.txt'),
        ]
        logdir = config.get_str('journaldir',
                                default=config.default_journal_dir)
        filename = filedialog.askopenfilename(initialdir=logdir,
                                              filetypes=ftypes)
        if self._route.load(filename):
            self.update_ui()
Exemple #17
0
 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
Exemple #18
0
def plugin_start3(plugin_dir):
    """
    Load this plugin into EDMC
    """
    try:
        config.get_str('L3_shipyard_provider')
    except:
        config.set('L3_shipyard_provider', 'EDSM')
    try:
        config.get_str('L3_system_provider')
    except:
        config.set('L3_system_provider', 'none')
    try:
        config.get_str('L3_station_provider')
    except:
        config.set('L3_station_provider', 'none')
    try:
        config.get_str('EDSM_id')
    except:
        config.set('EDSM_id', '')
    print("L3-37 started")
    return "L3-37"
Exemple #19
0
def get_sys_state():
    if (this.debug):
        this.log.debug("get_sys_state")
        this.log.debug("show_all_bgs: " + str(this.show_all_bgs))
    this.rurl = config.get_str("ugc_rurl")
    this.paras = {
        'Content-type': 'application/json',
        'Accept': 'text/plain',
        'version': this.__VERSION__,
        "br": this.__MINOR__,
        "branch": this.__BRANCH__,
        "cmdr": str(this.send_cmdr),
        "uuid": this.UUID,
        "token": this.Hash,
        "onlyBGS": str(this.show_all_bgs)
    }
    try:
        sys_state_data = requests.get(this.rurl, headers=this.paras)
    except:
        return
        this.sys_state = "API-Server ERROR"
        return
    if (sys_state_data.status_code > 202):
        try:
            updateMainUi(tick_color="white", systems_color="red")
        except:
            print("BGS-Plugin")
    if (sys_state_data.status_code > 405):
        return
        this.sys_state = "API-Server ERROR"
    else:
        jsonstring = sys_state_data.content.decode()
        systemlist = json.loads(jsonstring)
        if this.show_all_cfg.get():
            this.sys_state = pprint_list(systemlist)
        else:
            this.sys_state = pprint_list(systemlist[0])
    return
Exemple #20
0
def plugin_start3(plugin_dir: str) -> str:
    this.log.info("" + str(this.__VERSION__) + "." + this.__MINOR__ + " " +
                  str(this.__BRANCH__))
    this.log.debug('Starting worker thread...')
    fetch_debug()
    fetch_gl_cmd()
    fetch_update()
    fetch_send_cmdr()
    fetch_show_all()
    fetch_slow_state()
    get_ugc_tick()
    if not config.get_str("ugc_wurl"):
        config.set("ugc_wurl", this.SEND_TO_URL)
    if not config.get_str("ugc_rurl"):
        config.set("ugc_rurl", this.STATE_URL)
    this.rurl = config.get_str("ugc_rurl")
    this.wurl = config.get_str("ugc_wurl")
    if this.debug:
        this.log.debug(str(this.rurl))
        this.log.debug(str(this.wurl))
        this.log.debug(str(this.cmd))
        this.log.debug(str(this.tick))
    if config.get_str("ugc_cmdr"):
        this.CMDr = config.get_str("ugc_cmdr").encode("ascii",
                                                      "replace").decode()
        crypter()
    this.thread = Thread(target=worker, name='UGC worker')
    this.thread.daemon = True
    this.thread.start()
    get_sys_state()
    this.dstate = Thread(target=Late_State, name='UGC worker')
    this.dstate.daemon = True
    this.dstate.start()

    this.log.debug('Done.')
    return this.CONFIG_MAIN
Exemple #21
0
def plugin_prefs(parent, cmdr, is_beta):
    if not config.get_str("ugc_cmdr"):
        config.set("ugc_cmdr", cmdr.encode("ascii", "replace").decode())
        this.CMDr = config.get_str("ugc_cmdr")
        crypter()
    this.paras = {
        'Content-type': 'application/json',
        'Accept': 'text/plain',
        'version': this.__VERSION__,
        "br": this.__MINOR__,
        "branch": this.__BRANCH__,
        "cmdr": str(this.send_cmdr),
        "uuid": this.UUID,
        "token": this.Hash,
        "onlyBGS": str(this.show_all_bgs)
    }
    PADX = 10
    BUTTONX = 12  # indent Checkbuttons and Radiobuttons
    PADY = 2
    this.wurl = config.get_str("ugc_wurl")
    this.rurl = config.get_str("ugc_rurl")
    frame = nb.Frame(parent)
    #Config Entry for Data-Receiver URL
    this.wurl_label = nb.Label(frame, text="Sende URL")
    this.wurl_label.grid(row=11, padx=PADX, sticky=tk.W)
    this.wurl_cfg = nb.Entry(frame)
    this.wurl_cfg.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
    this.wurl_cfg.insert(0, this.wurl)
    #Config Entry for Data-Receiver URL
    this.rurl_label = nb.Label(frame, text="State URL")
    this.rurl_label.grid(row=12, padx=PADX, sticky=tk.W)
    this.rurl_cfg = nb.Entry(frame)
    this.rurl_cfg.grid(row=12, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
    this.rurl_cfg.insert(0, this.rurl)
    #Config Entry for Verify-Token
    this.vtk_label = nb.Label(frame, text="Verify Token")
    this.vtk_label.grid(row=13, padx=PADX, sticky=tk.W)
    this.vtk_cfg = nb.Entry(frame)
    this.vtk_cfg.grid(row=13, column=1, padx=PADX, pady=PADY, sticky=tk.EW)
    this.vtk_cfg.insert(0, "")
    #config interface
    nb.Checkbutton(frame,
                   text="CMDr Namen übertragen",
                   variable=this.send_cmdr_cfg).grid(columnspan=2,
                                                     padx=BUTTONX,
                                                     pady=(5, 0),
                                                     sticky=tk.W)
    nb.Checkbutton(frame,
                   text="Gesamte Liste Zeigen",
                   variable=this.show_all_cfg).grid(columnspan=2,
                                                    padx=BUTTONX,
                                                    pady=(5, 0),
                                                    sticky=tk.W)
    nb.Checkbutton(frame,
                   text="Nur BGS relevante zeigen",
                   variable=this.show_all_bgs_cfg).grid(columnspan=2,
                                                        padx=BUTTONX,
                                                        pady=(5, 0),
                                                        sticky=tk.W)
    nb.Checkbutton(frame, text="Auto Update",
                   variable=this.update_cfg).grid(columnspan=2,
                                                  padx=BUTTONX,
                                                  pady=(5, 0),
                                                  sticky=tk.W)
    nb.Checkbutton(frame, text="Slow State",
                   variable=this.slow_state_cfg).grid(columnspan=2,
                                                      padx=BUTTONX,
                                                      pady=(5, 0),
                                                      sticky=tk.W)
    nb.Checkbutton(frame, text="Debug",
                   variable=this.debug_cfg).grid(columnspan=2,
                                                 padx=BUTTONX,
                                                 pady=(5, 0),
                                                 sticky=tk.W)
    nb.Label(frame, text="Textfarben: ").grid(columnspan=2,
                                              padx=5,
                                              pady=(2, 0),
                                              sticky=tk.W)
    nb.Label(frame, text="Green: Start Up").grid(columnspan=2,
                                                 padx=5,
                                                 pady=(0, 0))
    nb.Label(frame, text="Orange: Bussy").grid(columnspan=2,
                                               padx=5,
                                               pady=(0, 0))
    nb.Label(frame, text="White: Idle").grid(columnspan=2, padx=5, pady=(0, 0))
    nb.Label(frame, text="Red: Error").grid(columnspan=2, padx=5, pady=(0, 0))
    nb.Label(frame,
             text="Version: " + str(this.__VERSION__) + "." + this.__MINOR__ +
             " " + str(this.__BRANCH__)).grid(columnspan=2,
                                              padx=BUTTONX,
                                              pady=(5, 0),
                                              sticky=tk.W)
    nb.Label(frame, text="CMDr: " + str(cmdr)).grid(columnspan=2,
                                                    padx=BUTTONX,
                                                    pady=(5, 0),
                                                    sticky=tk.W)

    nb.Button(frame, text="Test",
              command=lambda: send_test(cmdr, is_beta)).grid(columnspan=2,
                                                             padx=BUTTONX,
                                                             pady=(5, 0),
                                                             sticky=tk.W)
    return frame
Exemple #22
0
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"
Exemple #23
0
def get_journal_path(*args):
    "Get the path to the journal directory, or to a subdirectory or filename in it."

    logdir = config.get_str('journaldir') or config.default_journal_dir
    return os.path.join(logdir, *args)
import json
import datetime as dt
from datetime import datetime
from pathlib import Path
from logging import Logger
from typing import Dict, Any
from config import config

file_location: str

if hasattr(config, 'get_str'):
    file_location = config.get_str("journaldir")
else:
    file_location = config.get("journaldir")
if file_location is None or file_location == "":
    file_location = config.default_journal_dir


class MissionIndexBuilder:
    def __init__(self, logger: Logger):
        self.__logger = logger
        datetime_of_two_weeks_ago: datetime = dt.datetime.now() - dt.timedelta(
            weeks=2)
        self._active_mission_events: dict[str, dict[int, Any]] = \
            self.__get_mission_events_of_all_cmdrs_since_timestamp(datetime_of_two_weeks_ago.timestamp())

    """
    Return an Object will all Mission-Related Events, mapped to each commander.
    Dictionary< CMDR Name, Dictionary< TimeStamp, Event > >
    """
Exemple #25
0
def plugin_prefs(parent, cmdr, is_beta):
    service_providers = [
        ['none', 'None'],
        ['eddb', 'EDDB'],
        ['edsm', 'EDSM'],
        ['Inara', 'Inara'],
    ]
    frame = nb.Frame(parent)
    row = 0
    system_frame = nb.Frame(frame, relief=tk.GROOVE)
    system_provider_label = nb.Label(
        system_frame,
        text="System information provider override: ",
        justify=tk.LEFT)
    system_provider_label.grid(column=0, row=row, pady=2, padx=2)
    row = row + 1
    this.system_provider_select = tk.StringVar()
    for mode in service_providers:
        b = nb.Radiobutton(system_frame,
                           text=mode[1],
                           variable=this.system_provider_select,
                           value=mode[0])
        b.grid(column=0, row=row, sticky="W", padx=1)
        row = row + 1
    b.grid_configure(pady=2)
    try:
        this.system_provider_select.set(config.get_str('L3_system_provider'))
    except:
        this.system_provider_select.set("none")
    system_frame.grid(sticky="nsew")
    row = 0
    station_frame = nb.Frame(frame, relief=tk.GROOVE)
    station_provider_label = nb.Label(
        station_frame,
        text="Station information provider override: ",
        justify=tk.LEFT)
    station_provider_label.grid(column=0, row=row, pady=2, padx=2)
    row = row + 1
    this.station_provider_select = tk.StringVar()
    try:
        this.station_provider_select.set(config.get_str('L3_station_provider'))
    except:
        this.station_provider_select.set("none")
    for mode in service_providers:
        b = nb.Radiobutton(station_frame,
                           text=mode[1],
                           variable=this.station_provider_select,
                           value=mode[0])
        b.grid(column=0, row=row, sticky="W", padx=1)
        row = row + 1
        b.grid_configure(pady=2)
        station_frame.grid(sticky="nsew")

    shipyard_frame = nb.Frame(frame, relief=tk.GROOVE)
    shipyard_provider_label = nb.Label(shipyard_frame,
                                       text="Fleet information provider: ",
                                       justify=tk.LEFT)
    shipyard_provider_label.grid(column=2, row=0, pady=2)
    this.shipyard_provider_select = tk.StringVar()
    try:
        this.shipyard_provider_select.set(
            config.get_str('L3_shipyard_provider'))
    except:
        this.shipyard_provider_select.set("EDSM")
    modes = ['EDSM', 'Inara']
    row = 0
    for mode in modes:
        b = nb.Radiobutton(shipyard_frame,
                           text=mode,
                           variable=this.shipyard_provider_select,
                           value=mode)
        b.grid(column=3, row=row, sticky="W", padx=1)
        row = row + 1
    b.grid_configure(pady=2)
    EDSM_id_label = nb.Label(
        shipyard_frame,
        text=
        "To view your ships in EDSM,\nenter the numbers that follow id/\nin the URL for your EDSM profile page: ",
        justify=tk.LEFT)
    EDSM_id_label.grid(column=2, row=2, pady=2)
    this.EDSM_id_entry = nb.Entry(shipyard_frame)
    this.EDSM_id_entry.grid(column=3, row=2)
    try:
        this.EDSM_id_entry.delete(0, tk.END)
        this.EDSM_id_entry.insert(0, config.get_str('EDSM_id'))
    except:
        pass
    shipyard_frame.grid(column=1, row=1, sticky="nsew")
    return frame
Exemple #26
0
 def __init__(self, parent, *args, **options):
     WaferModule.__init__(self, parent, *args, **options)
     self.parent = parent
     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
     for cat in materials:
         for i in materials[cat]:
             materials[cat][i]['have'] = 0
             materials[cat][i]['simulated'] = 0
             materials[cat][i]['need'] = 0
     self.trader_frm_btns = {}
     self.tab_button_frm = tk.Frame(self)
     self.tab_button_frm.pack(fill='both', expand=1)
     self.bp_frm = VerticalScrolledFrame(self, bg=self.bg)
     self.bps = []
     self.bp_frm.pack(fill='both', expand=1)
     self.reset_btn = tk.Button(self,
                                text='Reset',
                                command=self.do_reset_btn)
     self.reset_btn.pack(fill='x', expand=1)
     self.bpcats = []
     for cat in ['Encoded', 'Raw', 'Manufactured']:
         y = 0
         self.trader_frm_btns[cat] = tk.Button(
             self.tab_button_frm,
             text=cat,
             command=lambda x=cat: self.show_dialog(x))
         self.trader_frm_btns[cat].pack(side='left', fill='both', expand=1)
     for slot in ['standard', 'internal', 'hardpoints']:
         for k, v in coriolis_dist['Modules'][slot].items():
             cat_name = str(coriolis_module_cats[slot][k]).title()
             if k in coriolis_dist['Modifications']['modules']:
                 if len(coriolis_dist['Modifications']['modules'][k]
                        ['blueprints']) > 0:
                     self.bpcats.append(
                         ToggledFrame(self.bp_frm.interior,
                                      text=cat_name,
                                      background=self.bg))
                     self.bpcats[-1].pack(fill='both', expand=1)
                     self.bpcats[-1].title_frame.config(background=self.bg)
                     self.bpcats[-1].toggle_button.config(
                         foreground=self.fg, background=self.bg)
                     self.bpcats[-1].sub_frame.config(background=self.bg)
                     for i in coriolis_dist['Modifications']['modules'][k][
                             'blueprints']:
                         name = coriolis_dist['Modifications'][
                             'blueprints'][i]['name']
                         for grade in blueprints[i]['grades']:
                             int_name = i
                             friendly_name = name + ' G' + grade
                             components = coriolis_dist['Modifications'][
                                 'blueprints'][i]['grades'][grade][
                                     'components']
                             self.bps.append(
                                 BlueprintFrame(self.bpcats[-1].sub_frame,
                                                self,
                                                friendly_name,
                                                int_name,
                                                components,
                                                foreground=self.fg,
                                                background=self.bg))
                             self.bps[-1].pack(fill='both', expand=1)
             else:
                 print('{} is missing!'.format(cat_name))
     if self.theme:
         self.bp_frm.interior.config(background=self.bg)
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()
    r.clipboard_append(text)