Ejemplo n.º 1
0
    def test_get_while_condition(self):
        """Test case for Language.get_while_condition"""

        # Create test set
        test_set = [(["while (cond1 || cond2 && are_met) {"], 0),
                    (["while cond1 or cond2 and are_met:"], 0)]

        # Create expected results test set
        res_set = [
            "(cond1 || cond2 && are_met)", "cond1 or cond2 and are_met:"
        ]

        # Run test for all tests in test_set
        for i in range(len(test_set)):

            # Test function with inputs and expected outputs
            self.assertEqual(Language().get_while_condition(*test_set[i]),
                             res_set[i])
Ejemplo n.º 2
0
def modifyMessage(bot_instance, message):
  chatID = message.chat.id
  checkChat(chatID)
  currentChat = Chats.getChat(chatID)

  # * Setting bot replies
  message.replies = Language(message.chat.id).strs

  # ? Resposes
  # * Saving bot responses to the DB trough ReponsesManager class and deleting old messages
  if not message.text is None and '/' in message.text:
    deleteAfter = currentChat.settings['removeAfter']['value']

    editor = ResponsesManager(currentChat)
    editor.addResponse(message.message_id)

    try:
      # * Deleting a reponse and all connected messages. Will delete everywhere
      if len(currentChat.responses) > deleteAfter:
        # * Spltting information about the oldest reponses into variables and deleting
        # * "main" nessage + other message, which were sent when the command was sent

        # * Splitting info to access it easier
        oldestResponse = list(currentChat.responses.items())[0]
        oldestResponseChatId = oldestResponse[0]
        oldestResponseIds = oldestResponse[1]['connectedIDs']

        # * Deleting data from the DB and removing "main" message in the chat
        editor.deleteResponse(oldestResponseChatId)
        bot_instance.delete_message(chatID, oldestResponseChatId)

        # * Deleting other messages
        if oldestResponseIds:
          for chatId, addtionalIds in oldestResponseIds.items():
            if not isinstance(addtionalIds, list):
              addtionalIds = [addtionalIds]

            for id in addtionalIds:
              bot_instance.delete_message(chatId, id)

    except apihelper.ApiException as error:
      print(error)

    currentChat.save()
Ejemplo n.º 3
0
def install_lang(tele_id):
    session = scoped_session(session_factory)
    s = session()
    language = s.query(Language).filter(Language.tele_id == tele_id).first()

    if language:
        es = gettext.translation("big_two_text", localedir="locale", languages=[language.language])
    else:
        try:
            language = Language(tele_id=tele_id, language="en")
            s.add(language)
            s.commit()
        except:
            s.rollback()

        es = gettext.translation("big_two_text", localedir="locale", languages=["en"])

    es.install()
    session.remove()
Ejemplo n.º 4
0
    def __init__(self, verbose=True, dbpath="../agentdata"):
        self.__lastError = None
        self.output = print
        self.__clock = 0
        self.verbose = verbose
        self.windows = []

        self.attention = Attention(self)
        self.language = Language(self)

        self.bodyWindow = BodyWindow.create(self)

        self.memory = Memory(self, dbpath)
        self.workingMemory = WorkingMemory(self)

        self.currentWindow = self.bodyWindow

        #TODO: a memory window!!!
        self.memoryWindow = MemoryWindow.create(self)
        self.attention.start()
Ejemplo n.º 5
0
def makeQuotelang(parent, module):
    ulang = Language("quotelang", parent, module)
    lang = ulang.__impl__

    lang.newOp("`", 0, (None, ExpressionRule()))

    lang.newOp(
        "\\", 200,
        (None,
         SequenceRule(
             NamedRule('extra', Rep(LiteralRule("\\"))),
             ChoiceRule(
                 NamedRule('localmodule', LiteralRule("@")),
                 SequenceRule(
                     NamedRule('splice', Opt(LiteralRule('*'))),
                     ChoiceRule(
                         SequenceRule(LiteralRule("("), ExpressionRule(),
                                      LiteralRule(")")), ExpressionRule()))))))

    return ulang
Ejemplo n.º 6
0
    def test_get_class_definition(self):
        """Test case for Language.get_class_definition"""

        # Create test set
        test_set = [
            (["public class MyClass extends ParentClass implement MyIntr"], 0),
            (["class MyClass(ParentClass, MyIntr):"], 0)
        ]

        # Create expected results test set
        res_set = [
            "public class MyClass extends ParentClass implement MyIntr",
            "MyClass(ParentClass, MyIntr):"
        ]

        # Run test for all tests in test_set
        for i in range(len(test_set)):

            # Test function with inputs and expected outputs
            self.assertEqual(Language().get_class_definition(*test_set[i]),
                             res_set[i])
Ejemplo n.º 7
0
def start(message):
    """
  Sends a greeting message from config file
  and provides some basic bot configuration settings
  """

    chatID = message.chat.id

    language = Language(chatID).lang
    languageMarkup = getLanguageMarkup(language)

    bot.send_sticker(chatID, greetingStickerId)

    greetingString = message.replies.hi.format(message.from_user.first_name,
                                               bot.get_me().username,
                                               commands.h)

    bot.send_message(chatID,
                     greetingString,
                     reply_markup=languageMarkup,
                     parse_mode='html')
Ejemplo n.º 8
0
def sendGlobalTopWord(message):
    topWordText = ''
    chatId = message.chat.id

    # * Checking if we has statistics atleast in one chat
    if not Chats.objects(words__not__size=0):
        bot.send_message(chatId, message.replies.nos)
        return

    # * Here will be saved the chat object which was most commonly used word,
    # * none of the words in other chats weren't sent as much times
    # * as particular word in this chat was.

    chatWithTop = Chats()

    # * Searches for the chat, which has the most used word in it
    # * (more ditailed description of this is written above the 'chatWithTop' variable defenition)

    sentTimes = 0
    while Chats.objects(words__sentTimes__gt=sentTimes):
        allMatching = Chats.objects(words__sentTimes__gt=sentTimes)
        if len(allMatching) == 1 or len(allMatching) == sentTimes + 2:
            chatWithTop = allMatching[0]
            topWordText = chatWithTop.topWord.text

            break
        sentTimes += 1

    # * Looks for this word in every chat and add its writtenTime to general
    sentEverywhere = 0
    for chat in Chats.objects(words__text=topWordText):
        for word in chat.words:
            if word.text == topWordText:
                sentEverywhere += word.sentTimes

    resultString = Language(message).strs.gtw.format(topWordText,
                                                     sentEverywhere)
    bot.send_message(chatId,
                     resultString,
                     reply_markup=getDeleteMarkup(commands.gtw, message))
Ejemplo n.º 9
0
 def __init__(self,
              state,
              creator,
              players,
              msg,
              cur_king=None,
              cur_lady=None):
     self.state = state
     self.creator = creator
     self.players = players
     self.cur_king = cur_king
     self.cur_lady = cur_lady
     self.successful_exp = 0
     self.failed_exp = 0
     self.exp_size = [2, 2, 2, 2, 2]
     self.players_nick_to_id = dict()
     self.cur_voting_for_exp = dict.copy(players)
     self.cur_exp = []
     self.people_in_exp = dict()
     self.additional_roles = {
         'Morgana': False,
         'Mordred': False,
         'Oberon': False
     }
     self.additional_id = -1
     self.lady_lake = False
     self.order = []
     self.checked = []
     self.reg_btn = msg
     self.past_lady = []
     self.vote_msg_id = -1
     self.del_msg = []
     self.kings_in_row = 0
     self.chat_id = msg.chat.id
     try:
         self.language = languages[self.chat_id]
     except KeyError:
         self.language = Language()
         languages[self.chat_id] = self.language
Ejemplo n.º 10
0
def lang(msg):
    try:
        languages[msg.chat.id]
    except KeyError:
        languages[msg.chat.id] = Language()
    keyboard = telebot.types.InlineKeyboardMarkup()
    eng = telebot.types.InlineKeyboardButton(
        text=languages[msg.chat.id]["English"] + "🇬🇧",
        callback_data="lang eng " + str(msg.from_user.id))
    rus = telebot.types.InlineKeyboardButton(
        text=languages[msg.chat.id]["Russian"] + '🇷🇺',
        callback_data="lang rus " + str(msg.from_user.id))
    ukr = telebot.types.InlineKeyboardButton(
        text=languages[msg.chat.id]["Ukrainian"] + "🇺🇦",
        callback_data="lang ukr " + str(msg.from_user.id))

    keyboard.add(eng)
    keyboard.add(rus)
    keyboard.add(ukr)
    bot_send_message(msg.chat.id,
                     languages[msg.chat.id]["Choose language"],
                     reply_markup=keyboard)
Ejemplo n.º 11
0
def change_lang(bot, tele_id, message_id, data):
    new_language = data.split(",")[1]
    session = scoped_session(session_factory)
    s = session()
    language = s.query(Language).filter(Language.tele_id == tele_id).first()

    if language:
        language.language = new_language
    else:
        try:
            language = Language(tele_id=tele_id, language=language)
            s.add(language)
            s.commit()
        except:
            s.rollback()
            session.remove()
            return

    s.commit()
    session.remove()
    install_lang(tele_id)
    bot.editMessageText(text=_("Default language has been set"), chat_id=tele_id, message_id=message_id)
Ejemplo n.º 12
0
    def __init__(self,
                 maxlen=200,
                 lang=None,
                 vocab_limit=None,
                 val_size=0.1,
                 seed=42,
                 is_val=False,
                 is_test=False,
                 use_cuda=False,
                 save_lang=False,
                 use_extended_vocab=True):

        self.maxlen = maxlen
        self.use_cuda = use_cuda
        self.parser = None
        self.val_size = val_size
        self.seed = seed
        self.is_val = is_val
        self.is_test = is_test
        self.use_extended_vocab = use_extended_vocab

        self.data = [] # Will hold all data from a single file

        if self.is_test:
            lines = SequencePairDataset.test_src
        else:
            lines = SequencePairDataset.train_src

        for line in lines:
            inputs, outputs, _ = line.split('\t')
            inputsL = inputs.split(',')
            outputsL = outputs.split(',')
            self.data.append([inputsL, outputsL])

        if lang is None:
            lang = Language(vocab_limit, self.data)

        self.lang = lang
Ejemplo n.º 13
0
def main():
    global checkpoint, waiting, best_loss, start_epoch
    # Vocabulary
    if checkpoint is None:
        print("There isn't the checkpoint.")
        exit()
    language = Language(file_path_tokens_map=file_path_tokens_map, file_path_vectors_map=file_path_vectors_map)
    vocab_size = language.get_n_tokens()

    # Dataset
    korean_dataset = KoreanDataset(file_path_data=file_path_data, file_path_tokens_map=file_path_tokens_map,
                                   max_len_sentence=max_len_sentence, max_len_morpheme=max_len_morpheme,
                                   noise=noise, continuous=continuous)
    test_loader = torch.utils.data.DataLoader(korean_dataset, batch_size=batch_size,
                                              pin_memory=True, drop_last=True)

    # Load the checkpoint
    checkpoint = torch.load(checkpoint)
    start_epoch = checkpoint['epoch'] + 1
    waiting = checkpoint['waiting']
    model = checkpoint['model']
    model_optimizer = checkpoint['model_optimizer']

    model = model.to(device)

    # Loss function
    criterion_is_noise = nn.BCELoss().to(device)
    criterion_is_next = nn.BCELoss().to(device)
    with torch.no_grad():
        mean_loss = test(test_loader=test_loader,
                         model=model,
                         criterion_is_noise=criterion_is_noise,
                         criterion_is_next=criterion_is_next)

        best_loss = min(mean_loss, best_loss)
        print('BEST LOSS:', best_loss)
Ejemplo n.º 14
0
    def __init__(self):

        self.option = sys.argv[1]

        self.conf = Conf()
        self.home = self.conf.home
        self.currentpath = self.home + self.conf.get(
            'GENERAL', 'op_folder') + '/openplotter'

        Language(self.conf)

        wx.Frame.__init__(self,
                          None,
                          title=_('Fine calibration'),
                          size=(500, 300))

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(self.currentpath + '/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.CreateStatusBar()

        self.text = wx.StaticText(self, label=_('Error'), pos=(10, 10))

        self.gain = self.conf.get('AIS-SDR', 'gain')
        self.ppm = self.conf.get('AIS-SDR', 'ppm')
        self.channel = self.conf.get('AIS-SDR', 'gsm_channel')

        wx.StaticText(self,
                      label=_('gain: ').decode('utf8') + self.gain,
                      pos=(10, 70))
        wx.StaticText(self,
                      label=_('ppm: ').decode('utf8') + self.ppm,
                      pos=(100, 70))

        self.output = wx.TextCtrl(self,
                                  style=wx.TE_MULTILINE | wx.TE_READONLY
                                  | wx.TE_DONTWRAP,
                                  size=(480, 110),
                                  pos=(10, 90))

        self.button_close = wx.Button(self, label=_('Close'), pos=(300, 210))
        self.Bind(wx.EVT_BUTTON, self.close, self.button_close)

        self.button_calculate = wx.Button(self,
                                          label=_('Calculate'),
                                          pos=(400, 210))
        self.Bind(wx.EVT_BUTTON, self.calculate, self.button_calculate)

        if self.option == 'c':
            self.text.SetLabel(
                _('Press Calculate and wait for the system to calculate the ppm value with\nthe selected channel. Put the obtained value in "Correction (ppm)" field\nand enable SDR-AISreception. Estimated time: 1 min.'
                  ))
            wx.StaticText(self,
                          label=_('channel: ').decode('utf8') + self.channel,
                          pos=(200, 70))
        if self.option == 'b':
            self.text.SetLabel(
                _('Press Calculate and wait for the system to check the band. Write down\nthe strongest channel (power). If you do not find any channel try another\nband. Estimated time: 5 min.'
                  ))

        self.Centre()
Ejemplo n.º 15
0
def modifyMessage(bot_instance, message):
  # * Checking if a message id an a chat id match a those which are in the DB.
  # * Then we assume, that the message it's a new value for a setting, so we
  # * change it.

  currentChat = Chats.getChat(message.chat.id)
  
  if currentChat is None:
    return

  editMessageInfo = currentChat.settings.editMessageInfo

  if (editMessageInfo and
      editMessageInfo['requestMessageId'] + 1 == message.message_id and
      editMessageInfo['requestChatId'] == message.chat.id):

    try:
      editArgument = int(message.text.split()[0])

      # * Changing setting value and sending user a reponse
      originalChatId = editMessageInfo['originalChatId']
      chatWeToChange = Chats.getChat(originalChatId)
      strings = Language(originalChatId).strs
      originalChat = Chats.getChat(originalChatId)

      # * Checking if new value is not the same as it was before
      oldValue = Settings.getSettingsValue(originalChat, editMessageInfo['commandName'])
      print(editArgument, oldValue)
      if editArgument == oldValue:
        raise ValueError()

    except ValueError as e:
      print(e)
      bot.send_message(message.chat.id, strings.stg.valueIsWrong)
      editMessageInfo['requestMessageId'] = message.message_id + 1
      currentChat.save()

    # * Changes setting
    Settings.setSettingValue(
      chatWeToChange,
      editMessageInfo['commandName'],
      editArgument
    )

    # * Deleting the spare replies, when the number of saved replies
    # * is higher then the new value of removeAfter

    idsToRemove = []
    if editMessageInfo['commandName'] == 'removeAfter' and oldValue > editArgument:
      for i, response in enumerate(originalChat.responses.items()):
        if i >= oldValue - editArgument:
          break

        try:
          bot_instance.delete_message(originalChatId, int(response[0]))
          if response[1]['connectedIDs']:
            for chatId, ids in response[1]['connectedIDs'].items():
              for id in ids:
                # pass
                bot_instance.delete_message(int(chatId), id)
        except ApiException as e:
          print(e)

        idsToRemove.append(response[0])

      for toRemove in idsToRemove:
        del originalChat.responses[toRemove]
      originalChat.save()

    # * Updates settings message in the originalChat
    bot.edit_message_text(
      strings.stg.msgTitle,
      originalChatId,
      originalChat.settings.lastMessageId[0],
      reply_markup=settingsMarkup(originalChatId)
    )

    # * Answering
    bot.answer_callback_query(
      editMessageInfo['callbackId'],
      strings.stg.changeSuccess
    )
Ejemplo n.º 16
0
 def get_language(self):
     self.preds = [Predicate('subtree', 2)]
     self.funcs = [FuncSymbol('f', 2)]
     self.consts = [Const(x) for x in self.symbols]
     self.lang = Language(preds=self.preds, funcs=self.funcs,
                          consts=self.consts)
Ejemplo n.º 17
0
		def __init__(self):

			self.conf = Conf()
			self.home = self.conf.home
			self.op_folder = self.conf.op_folder

			Language(self.conf)
			
			title = _('Moitessier HAT Setup')

			wx.Frame.__init__(self, None, title=title, size=(710,460))
			
			self.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
			
			self.icon = wx.Icon(op_folder+'/static/icons/moitessier_hat.ico', wx.BITMAP_TYPE_ICO)
			self.SetIcon(self.icon)
			self.help_bmp = wx.Bitmap(self.op_folder + "/static/icons/help-browser.png", wx.BITMAP_TYPE_ANY)

			self.p = wx.lib.scrolledpanel.ScrolledPanel(self, -1, style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER)
			self.p.SetAutoLayout(1)
			self.p.SetupScrolling()
			self.nb = wx.Notebook(self.p)
			self.p_info = wx.Panel(self.nb)
			self.p_settings = wx.Panel(self.nb)
			self.p_update = wx.Panel(self.nb)
			self.p_configure = wx.Panel(self.nb)
			self.nb.AddPage(self.p_info, _('HAT info'))
			self.nb.AddPage(self.p_update, _('Install drivers'))
			self.nb.AddPage(self.p_configure, _('OpenPlotter configuration'))
			self.nb.AddPage(self.p_settings, _('Play with settings'))
			sizer = wx.BoxSizer()
			sizer.Add(self.nb, 1, wx.EXPAND)
			self.p.SetSizer(sizer)

##################################################################### info

			info_box = wx.StaticBox(self.p_info, -1, _(' Info '))

			self.button_get_info =wx.Button(self.p_info, label= _('Settings'))
			self.Bind(wx.EVT_BUTTON, self.on_get_info, self.button_get_info)

			self.button_statistics =wx.Button(self.p_info, label= _('Statistics'))
			self.Bind(wx.EVT_BUTTON, self.on_statistics, self.button_statistics)

			self.button_reset_statistics =wx.Button(self.p_info, label= _('Reset statistics'))
			self.Bind(wx.EVT_BUTTON, self.on_reset_statistics, self.button_reset_statistics)

			sensors_box = wx.StaticBox(self.p_info, -1, _(' Test sensors '))

			self.button_MPU9250 =wx.Button(self.p_info, label= _('MPU-9250'))
			self.Bind(wx.EVT_BUTTON, self.on_MPU9250, self.button_MPU9250)

			self.button_MS560702BA03 =wx.Button(self.p_info, label= _('MS5607-02BA03'))
			self.Bind(wx.EVT_BUTTON, self.on_MS560702BA03, self.button_MS560702BA03)

			self.button_Si7020A20 =wx.Button(self.p_info, label= _('Si7020-A20'))
			self.Bind(wx.EVT_BUTTON, self.on_Si7020A20, self.button_Si7020A20)

			self.logger = rt.RichTextCtrl(self.p_info, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP|wx.LC_SORT_ASCENDING)
			self.logger.SetMargins((10,10))

			help_button = wx.BitmapButton(self.p_info, bitmap=self.help_bmp, size=(self.help_bmp.GetWidth()+40, self.help_bmp.GetHeight()+10))
			help_button.Bind(wx.EVT_BUTTON, self.on_help)

			shop =wx.Button(self.p_info, label=_('Shop'))
			self.Bind(wx.EVT_BUTTON, self.onShop, shop)

			checkB =wx.Button(self.p_info, label=_('Check'))
			self.Bind(wx.EVT_BUTTON, self.onCheck, checkB)

			button_ok =wx.Button(self.p_info, label=_('Close'))
			self.Bind(wx.EVT_BUTTON, self.on_ok, button_ok)

			h_boxSizer1 = wx.StaticBoxSizer(info_box, wx.HORIZONTAL)
			h_boxSizer1.AddSpacer(5)
			h_boxSizer1.Add(self.button_get_info, 0, wx.ALL | wx.EXPAND, 5)
			h_boxSizer1.Add(self.button_statistics, 0, wx.ALL | wx.EXPAND, 5)
			h_boxSizer1.Add(self.button_reset_statistics, 0, wx.ALL | wx.EXPAND, 5)

			h_boxSizer3 = wx.StaticBoxSizer(sensors_box, wx.HORIZONTAL)
			h_boxSizer3.AddSpacer(5)
			h_boxSizer3.Add(self.button_MPU9250, 0, wx.ALL | wx.EXPAND, 5)
			h_boxSizer3.Add(self.button_MS560702BA03, 0, wx.ALL | wx.EXPAND, 5)
			h_boxSizer3.Add(self.button_Si7020A20, 0, wx.ALL | wx.EXPAND, 5)

			buttons = wx.BoxSizer(wx.HORIZONTAL)
			buttons.Add(help_button, 0, wx.ALL | wx.EXPAND, 0)
			buttons.Add(shop, 0, wx.LEFT | wx.EXPAND, 10)
			buttons.AddStretchSpacer(1)
			buttons.Add(checkB, 0, wx.ALL | wx.EXPAND, 0)
			buttons.Add(button_ok, 0, wx.LEFT | wx.EXPAND, 10)

			vbox3 = wx.BoxSizer(wx.VERTICAL)
			vbox3.Add(h_boxSizer1, 0, wx.ALL | wx.EXPAND, 5)
			vbox3.Add(h_boxSizer3, 0, wx.ALL | wx.EXPAND, 5)
			vbox3.Add(self.logger, 1, wx.ALL | wx.EXPAND, 5)
			vbox3.Add(buttons, 0, wx.ALL | wx.EXPAND, 5)

			self.p_info.SetSizer(vbox3)

##################################################################### settings

			gnss_box = wx.StaticBox(self.p_settings, -1, ' GNSS ')

			self.button_enable_gnss =wx.Button(self.p_settings, label= _('Enable'))
			self.Bind(wx.EVT_BUTTON, self.on_enable_gnss, self.button_enable_gnss)

			self.button_disable_gnss =wx.Button(self.p_settings, label= _('Disable'))
			self.Bind(wx.EVT_BUTTON, self.on_disable_gnss, self.button_disable_gnss)

			general_box = wx.StaticBox(self.p_settings, -1, _(' General '))

			self.button_reset =wx.Button(self.p_settings, label= _('Reset HAT'))
			self.Bind(wx.EVT_BUTTON, self.on_reset, self.button_reset)

			self.button_defaults =wx.Button(self.p_settings, label= _('Load defaults'))
			self.Bind(wx.EVT_BUTTON, self.on_defaults, self.button_defaults)

			ais_box = wx.StaticBox(self.p_settings, -1, ' AIS ')

			self.simulator = wx.CheckBox(self.p_settings, label=_('enable simulator'))

			interval_label = wx.StaticText(self.p_settings, -1, _('interval (ms)'))
			self.interval = wx.SpinCtrl(self.p_settings, min=1, max=9999, initial=1000)

			mmsi1_label = wx.StaticText(self.p_settings, -1, _('MMSI boat 1'))
			self.mmsi1 = wx.SpinCtrl(self.p_settings, min=111111, max=999999999, initial=5551122)

			mmsi2_label = wx.StaticText(self.p_settings, -1, _('MMSI boat 2'))
			self.mmsi2 = wx.SpinCtrl(self.p_settings, min=111111, max=999999999, initial=6884120)

			freq1_label = wx.StaticText(self.p_settings, -1, _('channel A [Hz]'))
			freq2_label = wx.StaticText(self.p_settings, -1, _('channel B [Hz]'))
			metamask_label = wx.StaticText(self.p_settings, -1, 'meta data')
			afcRange_label = wx.StaticText(self.p_settings, -1, 'AFC range [Hz]')

			self.rec1_freq1 = wx.SpinCtrl(self.p_settings, min=159000000, max=162025000, initial=161975000)
			self.rec1_freq2 = wx.SpinCtrl(self.p_settings, min=159000000, max=162025000, initial=162025000)
			self.rec1_metamask = wx.Choice(self.p_settings, choices=(_('none'),'RSSI'), style=wx.CB_READONLY)
			self.rec1_metamask.SetSelection(0)
			self.rec1_afcRange = wx.SpinCtrl(self.p_settings, min=500, max=2000, initial=1500)

			self.logger2 = rt.RichTextCtrl(self.p_settings, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP|wx.LC_SORT_ASCENDING)
			self.logger2.SetMargins((10,10))

			help_button = wx.BitmapButton(self.p_settings, bitmap=self.help_bmp, size=(self.help_bmp.GetWidth()+40, self.help_bmp.GetHeight()+10))
			help_button.Bind(wx.EVT_BUTTON, self.on_help)

			self.button_apply =wx.Button(self.p_settings, label=_('Apply changes'))
			self.Bind(wx.EVT_BUTTON, self.on_apply, self.button_apply)

			button_ok2 =wx.Button(self.p_settings, label=_('Close'))
			self.Bind(wx.EVT_BUTTON, self.on_ok, button_ok2)

			h_boxSizer2 = wx.StaticBoxSizer(gnss_box, wx.HORIZONTAL)
			h_boxSizer2.AddSpacer(5)
			h_boxSizer2.Add(self.button_enable_gnss, 1, wx.ALL | wx.EXPAND, 5)
			h_boxSizer2.Add(self.button_disable_gnss, 1, wx.ALL | wx.EXPAND, 5)

			h_boxSizer4 = wx.StaticBoxSizer(general_box, wx.HORIZONTAL)
			h_boxSizer4.AddSpacer(5)
			h_boxSizer4.Add(self.button_reset, 1, wx.ALL | wx.EXPAND, 5)
			h_boxSizer4.Add(self.button_defaults, 1, wx.ALL | wx.EXPAND, 5)

			h_boxSizer5 = wx.BoxSizer(wx.HORIZONTAL)
			h_boxSizer5.Add(h_boxSizer2, 1, wx.RIGHT | wx.EXPAND, 10)
			h_boxSizer5.Add(h_boxSizer4, 1, wx.ALL | wx.EXPAND, 0)

			h_boxSizer6 = wx.BoxSizer(wx.HORIZONTAL)
			h_boxSizer6.Add((0,0), 1, wx.LEFT | wx.EXPAND, 5)
			h_boxSizer6.Add(interval_label, 1, wx.LEFT | wx.EXPAND, 5)
			h_boxSizer6.Add(mmsi1_label, 1, wx.LEFT | wx.EXPAND, 5)
			h_boxSizer6.Add(mmsi2_label, 1, wx.LEFT | wx.EXPAND, 5)

			h_boxSizer7 = wx.BoxSizer(wx.HORIZONTAL)
			h_boxSizer7.Add(self.simulator, 1, wx.ALL | wx.EXPAND, 5)
			h_boxSizer7.Add(self.interval, 1, wx.ALL | wx.EXPAND, 5)
			h_boxSizer7.Add(self.mmsi1, 1, wx.ALL | wx.EXPAND, 5)
			h_boxSizer7.Add(self.mmsi2, 1, wx.ALL | wx.EXPAND, 5)

			rec1_labels = wx.BoxSizer(wx.HORIZONTAL)
			rec1_labels.Add(freq1_label, 1, wx.LEFT | wx.EXPAND, 5)
			rec1_labels.Add(freq2_label, 1, wx.LEFT | wx.EXPAND, 5)
			rec1_labels.Add(metamask_label, 1, wx.LEFT | wx.EXPAND, 5)
			rec1_labels.Add(afcRange_label, 1, wx.LEFT | wx.EXPAND, 5)

			receiver1 = wx.BoxSizer(wx.HORIZONTAL)
			receiver1.Add(self.rec1_freq1, 1, wx.ALL | wx.EXPAND, 5)
			receiver1.Add(self.rec1_freq2, 1, wx.ALL | wx.EXPAND, 5)
			receiver1.Add(self.rec1_metamask, 1, wx.ALL | wx.EXPAND, 5)
			receiver1.Add(self.rec1_afcRange, 1, wx.ALL | wx.EXPAND, 5)

			v_boxSizer8 = wx.StaticBoxSizer(ais_box, wx.VERTICAL)
			v_boxSizer8.Add(h_boxSizer6, 0, wx.ALL | wx.EXPAND, 0)
			v_boxSizer8.Add(h_boxSizer7, 0, wx.ALL | wx.EXPAND, 0)
			v_boxSizer8.AddSpacer(15)
			v_boxSizer8.Add(rec1_labels, 0, wx.ALL | wx.EXPAND, 0)
			v_boxSizer8.Add(receiver1, 0, wx.ALL | wx.EXPAND, 0)
	

			buttons2 = wx.BoxSizer(wx.HORIZONTAL)
			buttons2.Add(help_button, 0, wx.ALL | wx.EXPAND, 0)
			buttons2.AddStretchSpacer(1)
			buttons2.Add(self.button_apply, 0, wx.RIGHT | wx.EXPAND, 10)
			buttons2.Add(button_ok2, 0, wx.ALL | wx.EXPAND, 0)

			vbox4 = wx.BoxSizer(wx.VERTICAL)
			vbox4.Add(h_boxSizer5, 0, wx.ALL | wx.EXPAND, 5)
			vbox4.Add(v_boxSizer8, 0, wx.ALL | wx.EXPAND, 5)
			vbox4.Add(self.logger2, 1, wx.ALL | wx.EXPAND, 5)
			vbox4.Add(buttons2, 0, wx.ALL | wx.EXPAND, 5)

			self.p_settings.SetSizer(vbox4)

##################################################################### install

			kernel_box = wx.StaticBox(self.p_update, -1, _(' Current kernel version '))

			self.kernel_label = wx.StaticText(self.p_update, -1)

			packages_box = wx.StaticBox(self.p_update, -1, _(' Available packages '))

			self.packages_list = []
			self.packages_select = wx.Choice(self.p_update, choices=self.packages_list, style=wx.CB_READONLY)
			self.readAvailable()

			self.button_install =wx.Button(self.p_update, label=_('Install'))
			self.Bind(wx.EVT_BUTTON, self.on_install, self.button_install)

			downloadB =wx.Button(self.p_update, label=_('Download'))
			self.Bind(wx.EVT_BUTTON, self.onDownload, downloadB)

			drivers =wx.Button(self.p_update, label=_('All drivers'))
			self.Bind(wx.EVT_BUTTON, self.onDrivers, drivers)

			self.logger3 = rt.RichTextCtrl(self.p_update, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP|wx.LC_SORT_ASCENDING)
			self.logger3.SetMargins((10,10))

			help_button = wx.BitmapButton(self.p_update, bitmap=self.help_bmp, size=(self.help_bmp.GetWidth()+40, self.help_bmp.GetHeight()+10))
			help_button.Bind(wx.EVT_BUTTON, self.on_help)

			button_ok3 =wx.Button(self.p_update, label=_('Close'))
			self.Bind(wx.EVT_BUTTON, self.on_ok, button_ok3)

			v_kernel_box = wx.StaticBoxSizer(kernel_box, wx.VERTICAL)
			v_kernel_box.AddSpacer(5)
			v_kernel_box.Add(self.kernel_label, 0, wx.ALL | wx.EXPAND, 5)

			h_packages_box = wx.StaticBoxSizer(packages_box, wx.HORIZONTAL)
			h_packages_box.Add(self.packages_select, 1, wx.ALL | wx.EXPAND, 5)
			h_packages_box.Add(self.button_install, 0, wx.ALL | wx.EXPAND, 5)
			h_packages_box.Add(downloadB, 0, wx.ALL | wx.EXPAND, 5)
			h_packages_box.Add(drivers, 0, wx.ALL | wx.EXPAND, 5)

			buttons3 = wx.BoxSizer(wx.HORIZONTAL)
			buttons3.Add(help_button, 0, wx.ALL | wx.EXPAND, 0)
			buttons3.AddStretchSpacer(1)
			buttons3.Add(button_ok3, 0, wx.ALL | wx.EXPAND, 0)

			update_final = wx.BoxSizer(wx.VERTICAL)
			update_final.Add(v_kernel_box, 0, wx.ALL | wx.EXPAND, 5)
			update_final.Add(h_packages_box, 0, wx.ALL | wx.EXPAND, 5)
			update_final.Add(self.logger3, 1, wx.ALL | wx.EXPAND, 5)
			update_final.Add(buttons3, 0, wx.ALL | wx.EXPAND, 5)

			self.p_update.SetSizer(update_final)

##################################################################### configure

			checkConfB =wx.Button(self.p_configure, label= _('Check'))
			self.Bind(wx.EVT_BUTTON, self.onCheckConfB, checkConfB)

			self.logger4 = rt.RichTextCtrl(self.p_configure, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP|wx.LC_SORT_ASCENDING)
			self.logger4.SetMargins((10,10))

			help_button = wx.BitmapButton(self.p_configure, bitmap=self.help_bmp, size=(self.help_bmp.GetWidth()+40, self.help_bmp.GetHeight()+10))
			help_button.Bind(wx.EVT_BUTTON, self.on_help)

			button_ok4 =wx.Button(self.p_configure, label=_('Close'))
			self.Bind(wx.EVT_BUTTON, self.on_ok, button_ok4)

			buttons4 = wx.BoxSizer(wx.HORIZONTAL)
			buttons4.Add(help_button, 0, wx.ALL | wx.EXPAND, 0)
			buttons4.AddStretchSpacer(1)
			buttons4.Add(checkConfB, 0, wx.ALL | wx.EXPAND, 0)
			buttons4.Add(button_ok4, 0, wx.LEFT | wx.EXPAND, 10)

			vbox5 = wx.BoxSizer(wx.VERTICAL)
			vbox5.Add(self.logger4, 1, wx.ALL | wx.EXPAND, 5)
			vbox5.Add(buttons4, 0, wx.ALL | wx.EXPAND, 5)

			self.p_configure.SetSizer(vbox5)

#####################################################################

			self.Centre()
			self.read()
Ejemplo n.º 18
0
 def set(self, name: str, language: str) -> None:
     lang: Language = Language(name)
     lang.set_language(language)
Ejemplo n.º 19
0
    def __init__(self):
        self.ttimer = 100
        conf = Conf()
        self.currentpath = op_folder
        Language(conf)

        self.list_iter = []

        titleadd = ''
        if len(sys.argv) > 0:
            if sys.argv[1] == '10112':
                titleadd = _('NMEA 0183 input diagnostic')
            elif sys.argv[1] == '10113':
                titleadd = _('NMEA 0183 output diagnostic')

        wx.Frame.__init__(self, None, title=titleadd, size=(650, 435))
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        panel = wx.Panel(self, wx.ID_ANY)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.timer_act, self.timer)

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(self.currentpath + '/static/icons/kplex.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.logger = wx.TextCtrl(panel,
                                  style=wx.TE_MULTILINE | wx.TE_READONLY
                                  | wx.TE_DONTWRAP | wx.LC_SORT_ASCENDING)

        self.list = wx.ListCtrl(panel,
                                -1,
                                style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.list.InsertColumn(0, _('Device'), width=70)
        self.list.InsertColumn(1, _('Type'), width=50)
        self.list.InsertColumn(2,
                               _('Interval'),
                               wx.LIST_FORMAT_RIGHT,
                               width=70)
        self.list.InsertColumn(3, _('Data'), width=430)

        self.button_pause = wx.Button(panel, label=_('Pause'), pos=(555, 160))
        self.button_pause.Bind(wx.EVT_BUTTON, self.pause)

        sort = wx.Button(panel, label=_('Sort'), pos=(555, 200))
        sort.Bind(wx.EVT_BUTTON, self.sort)

        nmea = wx.Button(panel, label=_('NMEA info'), pos=(555, 240))
        nmea.Bind(wx.EVT_BUTTON, self.nmea_info)

        self.pause_all = 0

        htextbox = wx.BoxSizer(wx.HORIZONTAL)
        htextbox.Add(self.logger, 1, wx.ALL | wx.EXPAND, 5)

        hlistbox = wx.BoxSizer(wx.HORIZONTAL)
        hlistbox.Add(self.list, 1, wx.ALL | wx.EXPAND, 5)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(self.button_pause, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(sort, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(nmea, 0, wx.RIGHT | wx.LEFT, 5)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(htextbox, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(hlistbox, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 0)
        panel.SetSizer(vbox)

        self.CreateStatusBar()
        self.Centre()

        self.s2 = ''
        self.status = ''
        self.data = []
        self.baudc = 0
        self.baud = 0

        self.timer.Start(self.ttimer)
Ejemplo n.º 20
0
    def __init__(self):
        self.conf = Conf()
        self.home = self.conf.home
        self.op_folder = op_folder
        self.help_bmp = wx.Bitmap(
            self.op_folder + "/static/icons/help-browser.png",
            wx.BITMAP_TYPE_ANY)
        Language(self.conf)
        wx.Frame.__init__(self,
                          None,
                          title=_('Kplex GUI - NMEA 0183 Multiplexer'),
                          size=(710, 460))
        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))
        self.icon = wx.Icon(self.op_folder + '/static/icons/kplex.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.list_kplex = CheckListCtrl(self, 650, 152)
        self.list_kplex.InsertColumn(0, _('Name'), width=130)
        self.list_kplex.InsertColumn(1, _('Type'), width=45)
        self.list_kplex.InsertColumn(2, _('io'), width=45)
        self.list_kplex.InsertColumn(3, _('Port/Address'), width=95)
        self.list_kplex.InsertColumn(4, _('Bauds/Port'), width=60)
        self.list_kplex.InsertColumn(5, _('inFilter'), width=55)
        self.list_kplex.InsertColumn(6, _('Filtering'), width=80)
        self.list_kplex.InsertColumn(7, _('outFilter'), width=60)
        self.list_kplex.InsertColumn(8, _('Filtering'), width=80)
        self.list_kplex.InsertColumn(9, _('Optional'), width=10)
        self.list_kplex.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.edit_kplex)

        diagnostic = wx.Button(self, label=_('Diagnostic'))
        diagnostic.Bind(wx.EVT_BUTTON, self.on_diagnostic_kplex)

        add = wx.Button(self, label=_('add'))
        add.Bind(wx.EVT_BUTTON, self.on_add_kplex)
        delete = wx.Button(self, label=_('delete'))
        delete.Bind(wx.EVT_BUTTON, self.on_delete_kplex)

        help_button = wx.BitmapButton(self,
                                      bitmap=self.help_bmp,
                                      size=(self.help_bmp.GetWidth() + 40,
                                            self.help_bmp.GetHeight() + 10))
        help_button.Bind(wx.EVT_BUTTON, self.on_help_kplex)
        restart = wx.Button(self, label=_('Restart'))
        restart.Bind(wx.EVT_BUTTON, self.on_restart_kplex)
        advanced = wx.Button(self, label=_('Advanced'))
        advanced.Bind(wx.EVT_BUTTON, self.on_advanced_kplex)
        apply_changes = wx.Button(self, label=_('Apply changes'))
        apply_changes.Bind(wx.EVT_BUTTON, self.on_apply_changes_kplex)
        cancel_changes = wx.Button(self, label=_('Cancel changes'))
        cancel_changes.Bind(wx.EVT_BUTTON, self.on_cancel_changes_kplex)

        hlistbox = wx.BoxSizer(wx.HORIZONTAL)
        hlistbox.Add(self.list_kplex, 1, wx.ALL | wx.EXPAND, 5)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add((0, 0), 1, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(add, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(delete, 0, wx.RIGHT | wx.LEFT, 5)

        hboxb = wx.BoxSizer(wx.HORIZONTAL)
        hboxb.Add(help_button, 0, wx.RIGHT | wx.EXPAND, 5)
        hboxb.Add(diagnostic, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 5)
        hboxb.Add(restart, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 5)
        hboxb.Add(advanced, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 5)
        hboxb.Add((0, 0), 1, wx.RIGHT | wx.LEFT, 5)
        hboxb.Add(apply_changes, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 5)
        hboxb.Add(cancel_changes, 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 5)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(hlistbox, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 5)
        vbox.AddSpacer(5)
        vbox.Add(hboxb, 0, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(vbox)
        self.CreateStatusBar()
        font_statusBar = self.GetStatusBar().GetFont()
        font_statusBar.SetWeight(wx.BOLD)
        self.GetStatusBar().SetFont(font_statusBar)
        self.Centre()
        self.manual_settings = ''
        self.read_kplex_conf()
Ejemplo n.º 21
0
    def __init__(self):
        self.conf = Conf()
        self.home = self.conf.home
        self.op_folder = self.conf.get('GENERAL', 'op_folder')
        self.currentpath = self.op_folder
        self.help_bmp = wx.Bitmap(
            self.op_folder + "/static/icons/help-browser.png",
            wx.BITMAP_TYPE_ANY)
        Language(self.conf)
        self.SK_settings = SK_settings(self.conf)

        self.available_operators = [
            'eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'btwn', 'cont', 'true',
            'false', 'null', 'nnull', 'empty', 'nempty'
        ]
        self.available_conditions = [
            '=', '!=', '<', '<=', '>', '>=',
            _('is between'),
            _('contains'),
            _('is true'), ('is false'),
            _('is null'),
            _('is not null'),
            _('is empty'),
            _('is not empty')
        ]

        self.available_source = [
            _('label'),
            _('type'),
            _('pgn'),
            _('src'),
            _('sentence'),
            _('talker')
        ]
        self.available_source_nr = [
            'label', 'type', 'pgn', 'src', 'sentence', 'talker'
        ]

        wx.Frame.__init__(self,
                          None,
                          title=_('SignalK input filter (uses node-red)'),
                          size=(710, 460))

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(self.op_folder + '/static/icons/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.list_triggers = wx.ListCtrl(self,
                                         -1,
                                         style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.list_triggers.InsertColumn(0, _('Signal K key'), width=240)
        self.list_triggers.InsertColumn(1, _('Source Type'), width=120)
        self.list_triggers.InsertColumn(2, _('Condition'), width=70)
        self.list_triggers.InsertColumn(3, _('Value'), width=90)
        self.list_triggers.InsertColumn(4, _('Value2'), width=60)

        self.list_triggers.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                self.on_select_triggers)
        self.list_triggers.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                self.on_deselected_triggers)
        self.list_triggers.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
                                self.on_edit_triggers)

        add_trigger = wx.Button(self, label=_('add'))
        add_trigger.Bind(wx.EVT_BUTTON, self.on_add_trigger)

        delete_trigger = wx.Button(self, label=_('delete'))
        delete_trigger.Bind(wx.EVT_BUTTON, self.on_delete_trigger)

        diagnostic = wx.Button(self, label=_('SK Diagnostic'))
        diagnostic.Bind(wx.EVT_BUTTON, self.on_diagnostic_SK)

        reset_skf = wx.Button(self, label=_('Restart'))
        reset_skf.Bind(wx.EVT_BUTTON, self.reset_sensors)

        help_button = wx.BitmapButton(self,
                                      bitmap=self.help_bmp,
                                      size=(self.help_bmp.GetWidth() + 40,
                                            self.help_bmp.GetHeight() + 10))
        help_button.Bind(wx.EVT_BUTTON, self.on_help_filter)

        apply_changes = wx.Button(self, label=_('Apply changes'))
        apply_changes.Bind(wx.EVT_BUTTON, self.on_apply_changes_triggers)
        cancel_changes = wx.Button(self, label=_('Cancel changes'))
        cancel_changes.Bind(wx.EVT_BUTTON, self.on_cancel_changes_triggers)

        hlistbox_but = wx.BoxSizer(wx.VERTICAL)
        hlistbox_but.Add(add_trigger, 0, wx.ALL, 5)
        hlistbox_but.Add(delete_trigger, 0, wx.ALL, 5)

        hlistbox = wx.BoxSizer(wx.HORIZONTAL)
        hlistbox.Add(self.list_triggers, 1, wx.ALL | wx.EXPAND, 5)
        hlistbox.Add(hlistbox_but, 0, wx.RIGHT | wx.LEFT, 0)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(help_button, 0, wx.ALL, 0)
        hbox.Add(diagnostic, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(reset_skf, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.AddStretchSpacer(1)
        hbox.Add(apply_changes, 0, wx.RIGHT | wx.LEFT, 5)
        hbox.Add(cancel_changes, 0, wx.RIGHT | wx.LEFT, 5)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(hlistbox, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(vbox)

        self.read_triggers()
Ejemplo n.º 22
0
 def __init__(self):
     self.language = Language()
Ejemplo n.º 23
0
def settingsMarkup(chatID):
  markup = InlineKeyboardMarkup()
  currentSettings = Chats.objects(ID=chatID).get().settings
  settingsStrings = Language(chatID).strs.stg.strings

  for index, setting in enumerate(currentSettings):

    # * Will stop the foop if we have already iterated through all settings.
    # * Has to be stopped because "settings" object contains not only settings values,
    # * but some additional info connected to /settings command

    if index >= len(settingsStrings):
      break

    isOnString = '❌'
    settingObject = currentSettings[setting]

    if isinstance(settingObject, bool) and settingObject:
      isOnString = '✅'
    elif isinstance(settingObject, dict) and settingObject['haveTo']:
      isOnString = '✅'

    # * Creaing and adding all buttons to the markup. Will create using 2D array in config
    newButtons = []
    for index, buttonInfo in enumerate(settingsStrings[index]):
      buttonText = buttonInfo[0]

      # * Formating button text if can be formated
      if canFormat(buttonText):
        buttonText = buttonText.format(settingObject['value'])

      tempButton = InlineKeyboardButton(
        f'{buttonText}',
        callback_data=buttonInfo[1],
      )

      if not index:
        tempButton = InlineKeyboardButton(
          f'{buttonText} {isOnString}',
          callback_data=buttonInfo[1]
        )

      newButtons.append(tempButton)
    markup.row(*newButtons)

  # ? Additional buttons
  buttonText = Language(chatID).strs.stg

  # * Editing button
  markup.row(InlineKeyboardButton(
    buttonText.editButtonValue,
    callback_data=additionalButtonCallbacks[0],
  ))

  # * Button to get more info
  markup.row(InlineKeyboardButton(
    buttonText.moreInfoButtonValue,
    callback_data=additionalButtonCallbacks[1]
  ))

  # * Button to move to Bot's chat
  addUrlButton(markup, Language(chatID).strs.goToBot[0], bot.get_me().username)

    # tempButton = InlineKeyboardButton(
    #   f'{settingsStrings[index][0]} {isOnString}',
    #   callback_data=settingsStrings[index][1]
    # )

    # markup.add(tempButton)

  return markup
Ejemplo n.º 24
0
def makeLanguages(logixModuleName, homedir, moduledict):
    import pycompile

    pycompile.installRootopCompilers()

    modname = logixModuleName + ".base"

    quotelang = makeQuotelang(parent=None, module=modname)
    syntaxlang = makeSyntaxlang(parent=quotelang, module=modname)
    langlang = makeLangLang(syntaxlang, parent=quotelang, module=modname)
    syntaxlang.__impl__.addOp(langlang.__impl__.getOp("(^"))

    global defaultBaseLang
    defaultBaseLang = langlang

    # {{{ baselang = create baselang (possibly from cache)
    baselang = Language("base", langlang, modname)

    filename = homedir + "/base.lx"
    env = dict(__name__=modname, base=baselang, langlang=langlang)

    def persistent_load(pid):
        res = {
            'nothing': nothing,
            'eol': Tokenizer.endOfLine,
            'eob': Tokenizer.endOfBlock,
            'eof': Tokenizer.endOfFile
        }.get(pid)
        if res: return res
        else: raise cPickle.UnpicklingError, 'Invalid persistent id'

    def persistent_id(x):
        return {
            id(nothing): "nothing",
            id(Tokenizer.endOfLine): "eol",
            id(Tokenizer.endOfBlock): "eob",
            id(Tokenizer.endOfFile): "eof"
        }.get(id(x))

    opFile = "%s/logix_opcache" % homedir

    if not path.exists(opFile):
        baselang.__impl__.parse(file(filename, 'U'), mode='exec', execenv=env)
        oplst = [x.syntax for x in baselang.__impl__.operators.values()]

        p = cPickle.Pickler(file(opFile, "w+"))
        p.persistent_id = persistent_id
        p.dump(oplst)

    else:
        p = cPickle.Unpickler(file(opFile))
        p.persistent_load = persistent_load
        for syntax in p.load():
            baselang.__impl__.newOpFromSyntax(syntax)
    # }}}

    pycompile.installPyCompilers(baselang.__impl__)

    # HACK: Fix up base lmodule
    mod = new.module(filename)
    mod.__file__ = filename
    vars(mod).update(env)
    moduledict[modname] = mod
    mod.langlang = langlang
    mod.syntaxlang = syntaxlang
    mod.quotelang = quotelang

    return quotelang, syntaxlang, langlang, baselang
Ejemplo n.º 25
0
import util
from sklearn.metrics import classification_report, confusion_matrix
import numpy as np
from keras.models import Model, Input
from sklearn.metrics import accuracy_score

if __name__ == '__main__':
	pre = Preprocessing()
	df_input = pre.data
	train_data = pre.train_data
	test_data = pre.test_data
	Y_train = pre.Y_train
	Y_test = pre.Y_test


	lng = Language(df_input)

	print("Preparing the language data")
	train_tokens = train_data['title'].apply(util.get_tokens)
	lng_data_train = lng.get_encoded_data(train_tokens)

	test_tokens = test_data['title'].apply(util.get_tokens)
	lng_data_test = lng.get_encoded_data(test_tokens)
	language_model = lng.lng_model
	print("training the language model (bi-lstm), this might take some time")
	language_model.fit(lng_data_train, Y_train, verbose=1, validation_split=0.2, nb_epoch=5)

	## printing precision_recall- language modality
	Y_pred = language_model.predict(lng_data_test, verbose=1)
	y_pred = np.array([np.argmax(pred) for pred in Y_pred])
	print("******************language modality scores(unimodal)*******************************")
Ejemplo n.º 26
0
    def __init__(self):

        self.option = sys.argv[1]

        self.conf = Conf()
        self.home = self.conf.home
        self.currentpath = self.conf.get('GENERAL', 'op_folder')

        Language(self.conf)

        wx.Frame.__init__(self,
                          None,
                          title=_('Fine calibration'),
                          size=(600, 320))

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(self.currentpath + '/static/icons/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.text = wx.StaticText(self, label=_('Error'), pos=(10, 10))

        self.ppm = self.conf.get('AIS-SDR', 'ppm')
        self.band = self.conf.get('AIS-SDR', 'band')
        self.channel = self.conf.get('AIS-SDR', 'gsm_channel')

        wx.StaticText(self,
                      label=_('Initial PPM: ').decode('utf8') + self.ppm,
                      pos=(10, 80))

        self.output = wx.TextCtrl(self,
                                  style=wx.TE_MULTILINE | wx.TE_READONLY
                                  | wx.TE_DONTWRAP,
                                  size=(580, 120),
                                  pos=(10, 100))

        self.button_close = wx.Button(self, label=_('Close'), pos=(400, 230))
        self.Bind(wx.EVT_BUTTON, self.close, self.button_close)

        self.button_calculate = wx.Button(self,
                                          label=_('Start'),
                                          pos=(500, 230))
        self.Bind(wx.EVT_BUTTON, self.calculate, self.button_calculate)

        if self.option == 'c':
            self.text.SetLabel(
                _('Press Start and wait for the system to calculate the PPM value.\nRound the resulting PPM to the nearest integer and copy it into "PPM" field.\nEstimated time: 1 min.'
                  ))
            wx.StaticText(self,
                          label=_('channel: ').decode('utf8') + self.channel,
                          pos=(200, 80))
        if self.option == 'b':
            self.text.SetLabel(
                _('Press Start and wait for the system to check the band.\nWrite down the strongest channel (power).\nIf you do not find any channel try another band.\nEstimated time: 5 min.'
                  ))
            wx.StaticText(self,
                          label=_('band: ').decode('utf8') + self.band,
                          pos=(200, 80))

        self.CreateStatusBar()

        self.Centre()
Ejemplo n.º 27
0
def stringForStats(chatID, words, wordNumbers, additionalInfo=False, chatName=None):
  """
  Returns a formated in a speial way string using all information
  bot has to use in /stats command and not only
  """

  if not words:
    return None

  wordWrittenTimes = 1
  result = []

  # * Creating an array of ceratiain format. It will look somethig like this
  # & [['Word(s), which was/were written 1 time(s).', '"first"'],
  # & ['Word(s), which was/were written 2 time(s).', '"second"']]

  while wordWrittenTimes <= max(wordNumbers):
    # * Skipping an iterations if we don't have words which where written this much times
    if wordWrittenTimes not in wordNumbers:
      wordWrittenTimes += 1
      continue

    # * Adds all info to the string, we get info from the DB
    oneLine = [Language(chatID).strs.s[1].format(wordWrittenTimes)]
    for i, word in enumerate(words):
      if wordWrittenTimes == wordNumbers[i]:
        oneLine.append (f'"{word}"')

    # * Adding one like of words which where written same number of times
    # * and incrementing the variable responcible for everything

    result.append(oneLine)
    wordWrittenTimes += 1

  messages = [[]]
  for item in result:
    messages[-1].append(item)

    if len(reduce(lambda a, b : ''.join(a) + ''.join(b), messages[-1])) >= 3000:
      messages.append([])

  # * Adding each to make a strings which will look something like this
  # & 'Word(s), which was/were written 1 time(s).\n"first"'

  allMessages = []
  for index, message in enumerate(messages):
    singleMessage = []
    if not chatName is None and not index:
      singleMessage.append(Language(chatID).strs.s[4].format(
        chatName
      ))

    for item in message:
      messageText = f'{item[0]}\n{", ".join(item[1:])}'
      singleMessage.append(messageText)
    allMessages.append(singleMessage)

  # * Making a string out of our array and adding more info to the string if we want to
  result = []
  currentChat = Chats.getChat(chatID)

  for message in allMessages:
    # * Checking if we need additional info and add it
    if message == allMessages[-1] and additionalInfo:
      message.append(Language(chatID).strs.s[0].format(
        currentChat.sentMessages,
        currentChat.sentWords
      ))

    # * Adding all together, to get a final result
    result.append('\n\n'.join(message))

  for i, item in enumerate(result):
    if len(item) >= 3000:
      del result[i]

      chuncks = []
      j = 0
      for j in range(0, len(item), item.index(',', j+2950) + 1):
        try:
          chuncks.append(item[0+j:item.index(',', j+2950) + 1])
        except Exception:
          chuncks.append(item[j - 1:])
        # string[0+i:length+string.index(',', i - 50)] for i in range(0, len(string), length)

      for j, chunk in enumerate(chuncks):
        result.insert(i + j, chunk)

  return result
Ejemplo n.º 28
0
def makeSyntaxlang(parent, module):
    op = Doc.new

    Seq = SequenceRule

    def makeRule(*args, **kws):
        className = args[0].__name__
        args = args[1:]
        return op(callOp, op(getRuleClass, className), *args, **kws)

    ulang = Language('syntax', parent, module)
    lang = ulang.__impl__

    # {{{ seq (continuation op)
    seq = lang.newOp('seq', 100, (ExpressionRule(), Rep1(TermRule())))
    seq.macro = lambda *seq: makeRule(SequenceRule, *seq)
    lang.continuationOp = seq
    # }}}

    # {{{ lit
    lang.newOp(
        'lit', 150,
        (None,
         ExpressionRule())).macro = lambda lit: makeRule(LiteralRule, lit)
    # }}}

    # {{{ ' and "
    lang.newOp(
        "'", 0,
        (None,
         SequenceRule(FreetextRule(r"[^'\\]*(?:\\.[^'\\]*)*", upto=False),
                      LiteralRule("'"))
         )).macro = lambda text: makeRule(LiteralRule, eval(repr(text)))

    lang.newOp(
        '"', 0,
        (None,
         SequenceRule(FreetextRule(r'[^"\\]*(?:\\.[^"\\]*)*', upto=False),
                      LiteralRule('"'))
         )).macro = lambda text: makeRule(LiteralRule, eval(repr(text)))
    # }}}

    # {{{ expr
    lang.newOp('expr', 200,
               (None,
                Opt(
                    SequenceRule(LiteralRule("@"),
                                 ChoiceRule(LiteralRule("^"), TermRule())))
                )).macro = lambda lang=None: makeRule(ExpressionRule, lang)
    # }}}

    # {{{ term
    lang.newOp('term', 200,
               (None,
                Opt(
                    SequenceRule(LiteralRule("@"),
                                 ChoiceRule(LiteralRule("^"), TermRule())))
                )).macro = lambda lang=None: makeRule(TermRule, lang)

    # }}}

    # {{{ block
    def block_macro(kind=None, x=None):
        if kind == "lang":
            return makeRule(BlockRule, x)
        elif kind == "rule":
            return makeRule(BlockRule, None, x)
        else:
            return makeRule(BlockRule)

    lang.newOp('block', 200,
               (None,
                Opt(
                    ChoiceRule(
                        SequenceRule(TrivialRule("lang"), LiteralRule("@"),
                                     ChoiceRule(LiteralRule("^"), TermRule())),
                        SequenceRule(TrivialRule("rule"), LiteralRule(":"),
                                     ExpressionRule()))))).macro = block_macro
    # }}}

    # {{{ symbol
    lang.newOp('symbol', 200,
               (None, None)).macro = lambda: makeRule(SymbolRule)
    # }}}

    # {{{ eol
    lang.newOp('eol', 0, (None, None)).macro = lambda: makeRule(EolRule)

    # }}}

    # {{{ debug
    def debug_macro(valx=None):
        if isinstance(valx, Symbol):
            valx2 = str(valx)
        else:
            valx2 = valx
        return makeRule(DebugRule, valx2)

    lang.newOp('debug', 0,
               (None,
                SequenceRule(LiteralRule("("), Opt(ExpressionRule()),
                             LiteralRule(")")))).macro = debug_macro
    # }}}

    # {{{ +
    lang.newOp(
        '+', 110,
        (ExpressionRule(), None)).macro = lambda rule: makeRule(Rep1, rule)
    # }}}

    # {{{ *
    lang.newOp(
        '*', 110,
        (ExpressionRule(), None)).macro = lambda rule: makeRule(Rep, rule)

    # }}}

    # {{{ $
    def dollar_macro(namex, rulex):
        if namex == data.none:
            n = None
        elif isinstance(namex, Symbol):
            n = str(namex)
        else:
            n = namex

        optOp = Symbol(syntaxlang_ns, "[")
        if isDoc(rulex, optOp) and rulex.contentLen() == 1:
            # The rule being named is optional ([...]) with no alternative.
            # Set the alternative to 'omit' (because it's named)
            return makeRule(NamedRule, n, op(optOp, rulex[0], '-'))
        else:
            return makeRule(NamedRule, n, rulex)

    lang.newOp('$', 120, (None,
                          SequenceRule(Opt(TermRule(), None), LiteralRule(':'),
                                       ExpressionRule()))).macro = dollar_macro
    # }}}

    # {{{ |
    lang.newOp(
        '|', 90,
        (ExpressionRule(),
         SequenceRule(ExpressionRule(),
                      Rep(SequenceRule(LiteralRule("|"), ExpressionRule())))
         )).macro = lambda *choices: makeRule(ChoiceRule, *choices)
    # }}}

    # {{{ (
    lang.newOp('(', 0, (None, SequenceRule(
        ExpressionRule(), LiteralRule(')')))).macro = lambda rulex: rulex

    # }}}

    # {{{ [
    def opt_macro(rulex, altx=None):
        if altx == '-':
            return makeRule(Opt, rulex)
        else:
            if isinstance(altx, Symbol):
                altx = str(altx)
            return makeRule(Opt, rulex, altx)

    lang.newOp('[', 200,
               (None,
                Seq(
                    ExpressionRule(), LiteralRule(']'),
                    Opt(
                        Seq(LiteralRule("/"),
                            ChoiceRule(LiteralRule("-"),
                                       ExpressionRule())))))).macro = opt_macro

    # }}}

    # {{{ <
    def trivial_macro(resultx=None):
        if isinstance(resultx, Symbol):
            resultx = str(resultx)

        if resultx is None:
            return makeRule(TrivialRule)
        else:
            return makeRule(TrivialRule, resultx)

    lang.newOp('<', 0,
               (None, SequenceRule(Opt(ExpressionRule()),
                                   LiteralRule('>')))).macro = trivial_macro
    # }}}

    # {{{ freetext
    lang.newOp(
        'freetext', 200,
        (None,
         SequenceRule(
             Opt(LiteralRule("upto"), False), LiteralRule('/'),
             FreetextRule(r"[^/\\]*(?:\\.[^/\\]*)*", upto=False),
             LiteralRule('/')))).macro = lambda upto, terminator: makeRule(
                 FreetextRule, terminator, bool(upto))
    # }}}

    # {{{ freetoken
    lang.newOp(
        'freetoken', 200,
        (None,
         SequenceRule(LiteralRule('/'),
                      FreetextRule(r"[^/\\]*(?:\\.[^/\\]*)*", upto=False),
                      LiteralRule('/'))
         )).macro = lambda terminator: makeRule(FreetokenRule, terminator)
    # }}}

    # {{{ optext
    lang.newOp('optext', 200,
               (None,
                SequenceRule(
                    NamedRule("lang", Opt(SymbolRule(), None)),
                    NamedRule(
                        "ops",
                        Rep(
                            SequenceRule(
                                LiteralRule('"'),
                                FreetextRule(r'[^\\"]*(?:\\.[^\\"]*)*',
                                             upto=False), LiteralRule('"')))),
                    Opt(LiteralRule("oneline"), False), LiteralRule('/'),
                    FreetextRule(r"[^/\\]*(?:\\.[^/\\]*)*", upto=False),
                    LiteralRule('/'))
                )).macro = lambda oneline, terminator, lang, ops: makeRule(
                    OptextRule, lang,
                    Doc(listOp, [eval('"%s"' % op)
                                 for op in ops]), bool(oneline), terminator)
    # }}}

    # {{{ "symbol:"
    lang.newOp('symbol:', 110,
               (None, ExpressionRule()
                )).macro = lambda rulex: makeRule(ParsedNameRule, rulex)
    # }}}

    return ulang
Ejemplo n.º 29
0
    def __init__(self):
        """Were the Main window start."""
        self.window = Gtk.Window()
        self.window.connect("delete_event", self.delete)
        self.window.set_border_width(0)
        self.window.set_default_size(700, 500)
        self.window.set_size_request(700, 500)
        self.window.set_title("GhostBSD Installer")
        self.window.set_border_width(0)
        self.window.set_icon_from_file(logo)
        mainHBox = Gtk.HBox(False, 0)
        mainHBox.show()
        mainVbox = Gtk.VBox(False, 0)
        mainVbox.show()
        self.window.add(mainHBox)
        mainHBox.pack_start(mainVbox, True, True, 0)
        # Create a new self.notebook
        self.notebook = Gtk.Notebook()
        mainVbox.pack_start(self.notebook, True, True, 0)
        self.notebook.show()
        self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(False)
        vbox = Gtk.VBox(False, 0)
        vbox.show()
        self.lang = Language()
        get_lang = self.lang.get_model()
        # self.lang = Installs()
        # get_lang = self.lang.get_model()
        vbox.pack_start(get_lang, True, True, 0)
        label = Gtk.Label("Language")
        self.notebook.insert_page(vbox, label, 0)

        # Set what page to start at Language
        self.notebook.set_current_page(0)

        # Create buttons
        self.table = Gtk.Table(1, 6, True)

        self.button1 = Gtk.Button(label='Back')
        self.button1.connect("clicked", self.back_page)
        self.table.attach(self.button1, 3, 4, 0, 1)
        self.button1.show()
        self.button1.set_sensitive(False)

        self.button2 = Gtk.Button(label='Cancel')
        self.button2.connect("clicked", self.delete)
        self.table.attach(self.button2, 4, 5, 0, 1)
        self.button2.show()

        self.button3 = Gtk.Button(label='Next')
        self.button3.connect("clicked", self.next_page, self.notebook)
        self.table.attach(self.button3, 5, 6, 0, 1)
        self.button3.show()

        self.table.set_col_spacings(5)
        self.table.show()
        # Create a new notebook
        self.nbButton = Gtk.Notebook()
        mainVbox.pack_end(self.nbButton, False, False, 5)
        self.nbButton.show()
        self.nbButton.set_show_tabs(False)
        self.nbButton.set_show_border(False)
        label = Gtk.Label("Button")
        self.nbButton.insert_page(self.table, label, 0)
        self.window.show_all()
Ejemplo n.º 30
0
    def __init__(self):

        self.conf = Conf()
        self.home = self.conf.home
        self.currentpath = self.home + self.conf.get(
            'GENERAL', 'op_folder') + '/openplotter'

        Language(self.conf)

        wx.Frame.__init__(self, None, title=_('SDR receiver'), size=(690, 370))

        self.SetFont(
            wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))

        self.icon = wx.Icon(self.currentpath + '/openplotter.ico',
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        wx.StaticBox(self, label='', size=(400, 170), pos=(10, 10))

        self.ais_sdr_enable = wx.CheckBox(self,
                                          label=_('Enable AIS reception'),
                                          pos=(20, 25))
        self.ais_sdr_enable.Bind(wx.EVT_CHECKBOX, self.OnOffAIS)

        self.gain = wx.TextCtrl(self, -1, size=(55, 32), pos=(150, 60))
        self.gain_label = wx.StaticText(self, label=_('Gain'), pos=(20, 65))
        self.ppm = wx.TextCtrl(self, -1, size=(55, 32), pos=(150, 95))
        self.correction_label = wx.StaticText(self,
                                              label=_('Correction (ppm)'),
                                              pos=(20, 100))

        self.ais_frequencies1 = wx.CheckBox(self,
                                            label=_('Channel A 161.975Mhz'),
                                            pos=(220, 60))
        self.ais_frequencies1.Bind(wx.EVT_CHECKBOX, self.ais_frequencies)
        self.ais_frequencies2 = wx.CheckBox(self,
                                            label=_('Channel B 162.025Mhz'),
                                            pos=(220, 95))
        self.ais_frequencies2.Bind(wx.EVT_CHECKBOX, self.ais_frequencies)

        #self.show_kplex6 =wx.Button(self, label=_('Inspector'), pos=(20, 140))
        #self.Bind(wx.EVT_BUTTON, self.show_kplex, self.show_kplex6)
        self.button_test_ppm = wx.Button(self,
                                         label=_('Take a look'),
                                         pos=(150, 140))
        self.Bind(wx.EVT_BUTTON, self.test_ppm, self.button_test_ppm)
        self.button_test_gain = wx.Button(self,
                                          label=_('Calibration'),
                                          pos=(275, 140))
        self.Bind(wx.EVT_BUTTON, self.test_gain, self.button_test_gain)

        wx.StaticBox(self,
                     label=_(' Fine calibration using GSM '),
                     size=(260, 170),
                     pos=(420, 10))
        self.bands_label = wx.StaticText(self, label=_('Band'), pos=(430, 50))
        self.bands_list = ['GSM850', 'GSM-R', 'GSM900', 'EGSM', 'DCS', 'PCS']
        self.band = wx.ComboBox(self,
                                choices=self.bands_list,
                                style=wx.CB_READONLY,
                                size=(100, 32),
                                pos=(430, 70))
        self.band.SetValue('GSM900')
        self.check_bands = wx.Button(self,
                                     label=_('Check band'),
                                     pos=(540, 70))
        self.Bind(wx.EVT_BUTTON, self.check_band, self.check_bands)
        self.channel_label = wx.StaticText(self,
                                           label=_('Channel'),
                                           pos=(430, 125))
        self.channel = wx.TextCtrl(self, -1, size=(55, 32), pos=(430, 143))
        self.check_channels = wx.Button(self,
                                        label=_('Fine calibration'),
                                        pos=(495, 140))
        self.Bind(wx.EVT_BUTTON, self.check_channel, self.check_channels)

        wx.StaticBox(self, label=_(' Radio '), size=(260, 120), pos=(420, 185))

        self.button_vhf_Rx = wx.Button(self, label='Gqrx', pos=(430, 210))
        self.Bind(wx.EVT_BUTTON, self.vhf_Rx, self.button_vhf_Rx)

        self.CreateStatusBar()

        self.Centre()

        self.Show(True)

        output = subprocess.check_output('lsusb')
        supported_dev = [
            '0bda:2832', '0bda:2838', '0ccd:00a9', '0ccd:00b3', '0ccd:00d3',
            '0ccd:00d4', '0ccd:00e0', '185b:0620', '185b:0650', '1f4d:b803',
            '1f4d:c803', '1b80:d3a4', '1d19:1101', '1d19:1102', '1d19:1103',
            '0458:707f', '1b80:d393', '1b80:d394', '1b80:d395', '1b80:d39d'
        ]
        found = False
        for i in supported_dev:
            if i in output: found = True
        if found:
            self.gain.SetValue(self.conf.get('AIS-SDR', 'gain'))
            self.ppm.SetValue(self.conf.get('AIS-SDR', 'ppm'))
            self.band.SetValue(self.conf.get('AIS-SDR', 'band'))
            self.channel.SetValue(self.conf.get('AIS-SDR', 'gsm_channel'))
            if self.conf.get('AIS-SDR', 'enable') == '1':
                self.ais_sdr_enable.SetValue(True)
                self.disable_sdr_controls()
            if self.conf.get('AIS-SDR', 'channel') == 'a':
                self.ais_frequencies1.SetValue(True)
            if self.conf.get('AIS-SDR', 'channel') == 'b':
                self.ais_frequencies2.SetValue(True)
        else:
            self.ais_sdr_enable.Disable()
            self.disable_sdr_controls()
            self.button_test_gain.Disable()
            self.button_test_ppm.Disable()
            self.bands_label.Disable()
            self.channel_label.Disable()
            self.band.Disable()
            self.channel.Disable()
            self.check_channels.Disable()
            self.check_bands.Disable()
            self.button_vhf_Rx.Disable()