Ejemplo n.º 1
0
def main(argv=None):
    if argv is None:
        argv = sys.argv
    parser = set_cmd_options()
    (options, args) = parser.parse_args(argv)

    if options.set_key:
        username = getpass.getuser()
        password = getpass.getpass()
        secret_key.set_key_to_keyring(username, password)
        return 0

    if options.write_settings:
        settings.write_default_settings(options.config_file)
        return 0
    settings.read_settings(options.config_file)
    if options.debug:
        settings.debug = True

    try:
        command = PimCmd()
        if len(args) == 1:
            print u"You have not specified a command!"
            print u"Use 'commands' to list the available commands."
            return -1
        cmd_name = args[1]
        params = args[2:]
        return command(cmd_name, *params)
    except (TypeError, NotEnoughArgsError), e:
        if settings.debug:
            print e
        print "Not enough arguments given."
        return -1
Ejemplo n.º 2
0
def main():
    args = parse_arguments()

    logger.addHandler(logging.StreamHandler())

    if (args.verbosity):
        logger.setLevel(args.verbosity)
    else:
        logger.setLevel(logging.INFO)
    logger.debug('yandex_reg version: %s', __version__)

    if args.config is not None:
        config_dir = args.config
        settings = read_settings(config_dir)

        browsers = {}
        cnt = 0
        ua = UserAgent()

        with open("proxy.txt", "r") as f:
            for line in f:
                user_agent = ua.random
                print(line, user_agent)

                URL = 'http://httpbin.org/ip'

                if cnt in browsers:
                    print("QUIT")
                    browsers[cnt].quit()

                proxyDict = {
                    "http": "http://" + line.strip(),
                    "https": "https://" + line.strip()
                }
                try:
                    r = requests.get(URL, proxies=proxyDict)
                    print(r.status_code)
                except Exception as e:
                    print("Proxy error")
                    continue

                chrome_options = webdriver.ChromeOptions()
                # chrome_options.add_argument('--proxy-server=%s' % line)
                # chrome_options.add_argument("user-agent=" + user_agent)
                # chrome_options.add_argument('--headless')
                browsers[cnt] = webdriver.Chrome(chrome_options=chrome_options)
                ya_reg_selenium(browsers[cnt], settings)
                cnt = cnt + 1

                if cnt == 1:
                    time.sleep(200)
                    cnt = 0
Ejemplo n.º 3
0
 def OnImport(self, evt):
     path = dialogs.get_file_to_open(self, wildcard=commands_wildcard, context="commands")
     if path:
         try:
             commands = read_settings(path)
             if isinstance(commands, dict):
                 commands = commands.get("commands", [])
             if isinstance(commands, list):
                 for command in commands:
                     if isinstance(command, dict) and "name" in command:
                         self.cmdlist.Append(command["name"], command)
         except Exception as e:
             dialogs.error(self, "Error importing commands file:\n\n%s" % e)
Ejemplo n.º 4
0
def load_settings(api_instance, settings):
    try:
        set = api_instance.get_settings()
        if set is None:
            set = read_settings()
        else:
            sett.write_settings(settings)
        settings.update_settings(set)
        return
    except Exception as e:
        print('Error while loading settings')
        print(e)

    set = sett.read_settings()
    settings.update_settings(set)
Ejemplo n.º 5
0
   def OnInit(self):
       self.tty, self.tp, self.timer, self.sen = settings.read_settings("settings")
       window = wx.Frame(None, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
       self.settings_window = wx.Frame(window, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
       window.SetTitle("inf0_warri0r - motion")
       window.SetSize((300, 150))
       window.Bind(wx.EVT_CLOSE,self.destroy)
       panel = wx.Panel(window)
       
       
       img = wx.Image("headder.jpg", wx.BITMAP_TYPE_ANY)
       imageCtrl = wx.StaticBitmap(panel, wx.ID_ANY,
                                         wx.BitmapFromImage(img))
       imageCtrl.SetBitmap(wx.BitmapFromImage(img))
       panel.Refresh()
        
        
       main_box = wx.BoxSizer(wx.VERTICAL)
       main_box.Add(panel, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
       button_box = wx.BoxSizer(wx.HORIZONTAL)
       self.cam_button = wx.Button(window,label="Cam")
       self.cam_button.Bind(wx.EVT_BUTTON, self.play)
       button_box.Add(self.cam_button, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) 
       self.active_button = wx.Button(window,label="Activate")
       self.active_button.Bind(wx.EVT_BUTTON, self.toggle_active)
       button_box.Add(self.active_button, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
       self.settings_button = wx.Button(window,label="Settings")
       button_box.Add(self.settings_button, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
       self.settings_button.Bind(wx.EVT_BUTTON, self.settings)   
       main_box.Add(button_box, 0, wx.EXPAND, 0)
       
       message_box = wx.BoxSizer(wx.VERTICAL)
       self.message_entry = wx.TextCtrl(window, size=(280, -1), name="a")
       self.message_entry.SetValue("---------------------")
       message_box.Add(self.message_entry, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
       main_box.Add(message_box, 0, wx.EXPAND, 0)

       window.SetSizer(main_box)
       window.Layout()
       window.Show()
       self.SetTopWindow(window)
       self.f = True
       self.f2 = True
       self.set_f = False
       return True
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-

import os
import unittest
import secret_key
import settings
settings.read_settings(None)
settings.get_key = secret_key.get_key_dummy
settings.test = True
settings.value = 'asdf1234'
settings.data_file = '/tmp/rm.txt'
import pim_errors
import pim_cmd
import info


class TestCmd(unittest.TestCase):

    def setUp(self):
        self.cmd = pim_cmd.PimCmd()

    def tearDown(self):
        if os.path.exists(settings.data_file):
            os.unlink(settings.data_file)

    def value_from_clipboard(self):
        if settings.dbus_support:
            import dbus
            bus = dbus.SessionBus()
            clipboard = bus.get_object('org.kde.klipper', '/klipper')
            content = clipboard.getClipboardContents()
Ejemplo n.º 7
0
    def __init__(self):
        super().__init__()

        # Create the main window
        self.ui = Ui_MainWindow()

        # Set upp the UI
        self.ui.setupUi(self)

        # Object for locking the serial port while sending/receiving data
        self.lock = threading.Lock()

        # Serial communication object
        self.ser = serial.Serial()

        # Initialize WMI communication with OpenHardwareMonitor
        # "initialize_hwmon()" returns a WMI object
        self.hwmon = openhwmon.initialize_hwmon()

        # QSettings object for storing the UI configuration in the OS native repository (Registry for Windows, ini-file for Linux)
        # In Windows, parameters will be stored at HKEY_CURRENT_USER/SOFTWARE/GridControl/App
        self.config = QtCore.QSettings('GridControl', 'App')

        # Get a list of available serial ports (e.g. "COM1" in Windows)
        self.serial_ports = grid.get_serial_ports()

        # Populate the "COM port" combo box with available serial ports
        self.ui.comboBoxComPorts.addItems(self.serial_ports)

        # Read saved UI configuration
        settings.read_settings(self.config, self.ui, self.hwmon)

        # Populates the tree widget on tab "Sensor Config" with values from OpenHardwareMonitor
        openhwmon.populate_tree(self.hwmon, self.ui.treeWidgetHWMonData,
                                self.ui.checkBoxStartSilently.isChecked())

        # System tray icon
        self.trayIcon = SystemTrayIcon(
            QtGui.QIcon(QtGui.QPixmap(":/icons/grid.png")), self)
        self.trayIcon.show()

        # Create a QThread object that will poll the Grid for fan rpm and voltage and HWMon for temperatures
        # The lock is needed in all operations with the serial port
        self.thread = polling.PollingThread(
            polling_interval=int(self.ui.comboBoxPolling.currentText()),
            ser=self.ser,
            lock=self.lock,
            cpu_sensor_ids=self.get_cpu_sensor_ids(),
            gpu_sensor_ids=self.get_gpu_sensor_ids(),
            cpu_calc="Max" if self.ui.radioButtonCPUMax.isChecked() else "Avg",
            gpu_calc="Max" if self.ui.radioButtonGPUMax.isChecked() else "Avg")

        # Connect signals and slots
        self.setup_ui_logic()

        # Setup UI parameters that cannot be defined in QT Designer
        self.setup_ui_design()

        # Store current horizontal slider values
        # Used for restoring values after automatic mode has been used
        self.manual_value_fan1 = self.ui.horizontalSliderFan1.value()
        self.manual_value_fan2 = self.ui.horizontalSliderFan2.value()
        self.manual_value_fan3 = self.ui.horizontalSliderFan3.value()
        self.manual_value_fan4 = self.ui.horizontalSliderFan4.value()
        self.manual_value_fan5 = self.ui.horizontalSliderFan5.value()
        self.manual_value_fan6 = self.ui.horizontalSliderFan6.value()

        # Minimize to tray if enabled
        if self.ui.checkBoxStartMinimized.isChecked():
            self.setWindowState(QtCore.Qt.WindowMinimized)
        else:
            self.show()

        # Initialize communication
        self.init_communication()
Ejemplo n.º 8
0
#
import gettext
from gettext import gettext as _

import comparetext
from feed import Feed
from filter import Filter
import logging
import settings
import utils

# setup gettext
gettext.textdomain('feedfilter')

feedfile = settings.read_argv()
settings.read_settings()

utils.setupLogger()

# read and parse filterfiles
wordfilter = Filter()
wordfilter.read_filterlist('./blackwordlist.txt')
wordfilter.read_filterlist(settings.sitename)

# Parse feed
feed = Feed(feedfile)
# For now we use the language without any regional variants
lang = feed.get_lang().split('-')[0]

wordlists = {}
for child in feed:
Ejemplo n.º 9
0
    "SERVER_PORT": 61086,

    # seconds between checks
    "CHECK_INTERVAL": 60,

    # list of directories to synchronize
    "DIRS": [
        ### "~" is expanded to the user directory (with os.path.expanduser)
        ### synchronizes ~/example/ with the remote name of "example"
        # "~/example",
        ### synchronizes ~/example/ with the remote name of "different-name"
        # ("~/example", "different-name"),
    ],
}
"""
(settings_dir, settings_path, settings) = read_settings("wolfebox", default_settings_str)
if settings["SERVER_NAME"] == "":
    sys.exit("ERROR: wolfebox is not configured properly. SERVER_NAME is blank.\nedit " + settings_path)
dirs = []
for maybe_tuple in settings["DIRS"]:
    if type(maybe_tuple) == tuple:
        path, name = maybe_tuple
    else:
        path = maybe_tuple
        name = os.path.split(maybe_tuple)[1]
    path = os.path.expanduser(path)
    dirs.append((path, name))
if len(dirs) == 0:
    sys.stderr.write("WARNING: no dirs have been configured for synchronization\n")

class IndexEntry:
Ejemplo n.º 10
0
    def new():
        """
        Creates a new settings object

        Returns:
            Setting: The new settings object
        """

        settings = read_settings()
        progress_bar_type, show_progress_bar, electrify_progress_bar, use_custom_progress_bar, custom_progress_bar, install_metrics = '', '', False, False, '', True

        try:
            install_metrics = settings['installMetrics']
        except:
            pass

        try:
            progress_bar_type = settings['progressBarType']
        except KeyError:
            progress_bar_type = 'default'

        try:
            show_progress_bar = settings['showProgressBar']
        except KeyError:
            show_progress_bar = True

        try:
            electrify_progress_bar = settings['electrifyProgressBar']
        except KeyError:
            electrify_progress_bar = False

        try:
            use_custom_progress_bar = settings['useCustomProgressBar']
        except KeyError:
            use_custom_progress_bar = False

        try:
            custom_progress_bar = settings['customProgressBar']
        except KeyError:
            custom_progress_bar = None

        if use_custom_progress_bar and not custom_progress_bar:
            use_custom_progress_bar = False

        try:
            settings['customProgressBar']['unfill_character'] = settings[
                'customProgressBar']['unfill_character'] if not settings[
                    'customProgressBar']['unfill_character'] == '' else ' '
        except KeyError:
            pass

        try:
            settings['customProgressBar']['fill_character']
        except KeyError:
            use_custom_progress_bar = False

        try:
            settings['customProgressBar']['unfill_character']
        except KeyError:
            try:
                settings['customProgressBar']['unfill_character'] = ' '
            except KeyError:
                use_custom_progress_bar = False

        return Setting(settings, progress_bar_type, show_progress_bar,
                       electrify_progress_bar, use_custom_progress_bar,
                       custom_progress_bar, install_metrics)
Ejemplo n.º 11
0
import settings
import pygame
import sys
import solver

# Настройка экрана
size = width, height = 1200, 600
screen = pygame.display.set_mode(size)
pygame.display.set_caption('Тетрис')

# Загрузка изображения - фона
background_image = pygame.image.load('background.jpg')
background_image = pygame.transform.scale(background_image, size)

# Читаем настройки
settings_config = settings.read_settings()

# Создание кнопок
start_game = Button(game,
                    450,
                    100,
                    300,
                    60,
                    'Новая игра',
                    78,
                    pygame.Color('pink'),
                    screen,
                    *(screen, settings_config),
                    border_color=pygame.Color('white'))

net_game = Button(net_game,
Ejemplo n.º 12
0
import discord
from chatterbot import ChatBot
from discord.ext.commands import Bot

from settings import read_settings, create_new_settings

# Discord bot initialization
# client = discord.Client()
description = '''Moby serves to protect, as well as be the host of the hit online series, the
Adventures of Tim and Moby!'''
MobyBot = Bot(command_prefix='!', description=description)

# Load settings file
options = {}
try:
    options = read_settings('settings.txt')
except:
    create_new_settings()
    print('Please configure the settings.txt file.')
    exit()

# "unpack" settings file
chat_bot_name = options['chat_bot_name']
bot_token = options['bot_token']
email_username = options['email_username']
email_password = options['email_password']
email_address = options['email_address']
email_smtp = options['email_smtp']
email_port = int(options['email_port'])
cowan_text_gateway = options['cowan_text_gateway']
client_email = options['client_email']
Ejemplo n.º 13
0
    def new():
        """
        Creates a new settings object

        Returns:
            Setting: The new settings object
        """

        settings = read_settings()
        progress_bar_type,  show_progress_bar, electrify_progress_bar, use_custom_progress_bar, custom_progress_bar, install_metrics, show_support_message = '', '', False, False, '', True, True

        try:
            install_metrics = settings['installMetrics']
        except:
            pass

        try:
            progress_bar_type = settings['progressBarType']
        except KeyError:
            progress_bar_type = 'default'

        try:
            show_progress_bar = settings['showProgressBar']
        except KeyError:
            show_progress_bar = True

        try:
            electrify_progress_bar = settings['electrifyProgressBar']
        except KeyError:
            electrify_progress_bar = False

        try:
           use_custom_progress_bar = settings['useCustomProgressBar']
        except KeyError:
            use_custom_progress_bar = False

        try:
           custom_progress_bar = settings['customProgressBar']
        except KeyError:
            custom_progress_bar = None

        if use_custom_progress_bar and not custom_progress_bar:
            use_custom_progress_bar = False

        try:
            settings['customProgressBar']['unfill_character'] = (
                settings['customProgressBar']['unfill_character']
                if settings['customProgressBar']['unfill_character'] != ''
                else ' '
            )

        except KeyError:
            pass

        try:
            settings['customProgressBar']['fill_character']
        except KeyError:
            use_custom_progress_bar = False

        try:
            settings['customProgressBar']['unfill_character']
        except KeyError:
            try:
                settings['customProgressBar']['unfill_character'] = ' '
            except KeyError:
                use_custom_progress_bar = False

        try:
            show_support_message = settings['showSupportMessage']
        except KeyError:
            show_support_message = True

        try:
            checksum = settings['checksumInstallers']
        except KeyError:
            checksum = True

        try:
            virus_check = settings['virusCheck']
        except KeyError:
            virus_check = False

        return Setting(settings, progress_bar_type, show_progress_bar, electrify_progress_bar, use_custom_progress_bar, custom_progress_bar, install_metrics, show_support_message, checksum, virus_check)
Ejemplo n.º 14
0
def search_parser(query, query_type):
    """
	[IN PROGRESS]
	"""

    ##-----------------------------------##
    ## Deal with a classic biblio search ##
    ##-----------------------------------##
    if (query_type == 1):

        ## Get the parameters for the search
        parameters = settings.read_settings()

        ## get list of PMID
        list_of_articles = ncbi_crawler.get_ListOfArticles(
            query, parameters['max_abstract_return'])

        ## Write results in a data file
        output_file = open("fetched/pubmed_abstract.txt", "w")
        for pmid in list_of_articles:
            abstract = ncbi_crawler.fetch_abstract(pmid)
            abstract = abstract.encode('ascii', 'ignore')
            output_file.write(">" + str(pmid) + "\n")
            output_file.write(abstract + "\n")
        output_file.close()

    ##-----------------------##
    ## Get Gene informations ##
    ##-----------------------##
    elif (query_type == 2):

        ## Collect information
        mg = mygene.MyGeneInfo()
        gene_info = mg.query(query, size=1)

        ## Check if we found something
        if (len(gene_info["hits"]) > 0):
            gene_name = gene_info["hits"][0]["name"]
            gene_symbol = gene_info["hits"][0]["symbol"]
            gene_taxid = gene_info["hits"][0]["taxid"]
            gene_entrez = gene_info["hits"][0]["entrezgene"]
            gene_id = gene_info["hits"][0]["_id"]

            ##-------------------------##
            ## Get Protein Information ##
            ##-------------------------##
            write_protein_information(gene_entrez)

            ##-----------------------##
            ## Get Pathways Involved ##
            ##-----------------------##
            pathways_fetched = kegg_crawler.get_involved_pathways(gene_entrez)
            pathways_file = open("fetched/pathways_involved.csv", "w")
            for pathway in pathways_fetched:
                pathways_file.write(pathway + "," + pathways_fetched[pathway] +
                                    "\n")
            pathways_file.close()

        else:
            gene_name = "No Gene Found"
            gene_symbol = "Nothing Found"
            gene_taxid = "Nothing Found"
            gene_entrez = "Nothing Found"
            gene_id = "Nothing Found"

        ## Write results in a data file
        ## <choucroute> separateur, beacause random
        ## char always present in gene name
        output_file = open("fetched/gene_information.csv", "w")
        output_file.write("name<choucroute>" + str(gene_name) + "\n")
        output_file.write("symbol<choucroute>" + str(gene_symbol) + "\n")
        output_file.write("taxid<choucroute>" + str(gene_taxid) + "\n")
        output_file.write("entrezgene<choucroute>" + str(gene_entrez) + "\n")
        output_file.write("id<choucroute>" + str(gene_id) + "\n")
        output_file.close()

    ##------------------##
    ## Work in progress ##
    ##------------------##
    elif (query_type == 3):
        print "Work in progress"

    ##---------------------------------##
    ## Wrong parameters initialization ##
    ##---------------------------------##
    else:
        print "What do you looking for ?"