コード例 #1
0
def experiment(n,
               iterations,
               X_testing,
               Y_testing,
               X_training,
               Y_training,
               center='ac',
               sample=1,
               M=None):
    config.reset()

    testing = 3
    matrix_of_weights = weights_matrix(n,
                                       iterations,
                                       X_training,
                                       Y_training,
                                       center=center,
                                       sample=sample,
                                       M=M)
    matrix_of_accuracies = []

    for weights in matrix_of_weights:
        accuracies = []
        for weight in weights:
            accuracy = compute_accuracy(weight, X_testing, Y_testing)
            accuracies.append(accuracy)
        matrix_of_accuracies.append(accuracies)

    matrix_of_accuracies = np.array(matrix_of_accuracies)
    sum_of_accuracies = matrix_of_accuracies.sum(axis=0)
    average_accuracies = sum_of_accuracies / n
    return average_accuracies
コード例 #2
0
    def UpdateSettings(self, handler, query):
        config.reset()
        for section in ['Server', '_tivo_SD', '_tivo_HD', '_tivo_4K']:
            self.each_section(query, section, section)

        sections = query['Section_Map'][0].split(']')[:-1]
        for section in sections:
            ID, name = section.split('|')
            if query[ID][0] == 'Delete_Me':
                config.config.remove_section(name)
                continue
            if query[ID][0] != name:
                config.config.remove_section(name)
                config.config.add_section(query[ID][0])
            self.each_section(query, ID, query[ID][0])

        if query['new_Section'][0] != ' ':
            config.config.add_section(query['new_Section'][0])
        config.write()

        if getattr(sys, 'frozen', False):
            if sys.platform == "win32":
                tivomak_path = os.path.join(os.path.dirname(sys.executable),
                                            'dshow', 'tivomak')
                tmakcmd = [
                    tivomak_path, '-set',
                    config.config.get('Server', 'tivo_mak')
                ]
                subprocess.Popen(tmakcmd, shell=True)

        handler.redir(SETTINGS_MSG, 5)
コード例 #3
0
ファイル: settings.py プロジェクト: hmblprogrammer/pytivo
    def Settings(self, handler, query):
        # Read config file new each time in case there was any outside edits
        config.reset()

        shares_data = []
        for section in config.config.sections():
            if not section.startswith(('_tivo_', 'Server')):
                if (not (config.config.has_option(section, 'type')) or
                    config.config.get(section, 'type').lower() not in
                    ['settings', 'togo']):
                    shares_data.append((section,
                                        dict(config.config.items(section,
                                                                 raw=True))))

        t = Template(SETTINGS_TEMPLATE, filter=EncodeUnicode)
        t.mode = buildhelp.mode
        t.options = buildhelp.options
        t.container = handler.cname
        t.quote = quote
        t.server_data = dict(config.config.items('Server', raw=True))
        t.server_known = buildhelp.getknown('server')
        t.hd_tivos_data = dict(config.config.items('_tivo_HD', raw=True))
        t.hd_tivos_known = buildhelp.getknown('hd_tivos')
        t.sd_tivos_data = dict(config.config.items('_tivo_SD', raw=True))
        t.sd_tivos_known = buildhelp.getknown('sd_tivos')
        t.shares_data = shares_data
        t.shares_known = buildhelp.getknown('shares')
        t.tivos_data = [(section, dict(config.config.items(section, raw=True)))
                        for section in config.config.sections()
                        if section.startswith('_tivo_')
                        and not section.startswith(('_tivo_SD', '_tivo_HD'))]
        t.tivos_known = buildhelp.getknown('tivos')
        t.help_list = buildhelp.gethelp()
        t.has_shutdown = hasattr(handler.server, 'shutdown')
        handler.send_html(str(t))
コード例 #4
0
    def test_set_methods(self):
        """ this tests all of the set methods since they need to work together """
        save_config_file = config.ConfigObject.CONFIG_FILE

        # Test the default with no file is 'unittest'
        config.reset()
        config.ConfigObject.CONFIG_FILE = 'badfile.xxx'
        self.assertEqual(config.get_environment(), 'unittest')

        config.ConfigObject.CONFIG_FILE = save_config_file

        # test that if we the database name we have an unknown environmentwe
        config.reset()
        config.set_database_name(':memory:')
        self.assertEqual(config.get_environment(), '????')

        # test that if we the database name we have an unknown environment
        config.reset()
        config.set_enviornment('test')
        self.assertTrue(config.get_database_name())

        # test that we have an instance and database
        config.reset()
        self.assertTrue(config.get_environment(
        ))  # All these values must be set... Can't test to what though
        self.assertTrue(config.get_database_name())
        self.assertTrue(config.get_database_instance())
        self.assertTrue(config.get_database())

        # test that the default pdf location is the temp directory
        config.reset()
        self.assertTrue(config.get_pdf_location())
        self.assertEqual(config.get_pdf_location(), config.get_temp_dir())
コード例 #5
0
def playAudio(path):
    conf.reset()
    if not xxx2wav(path):
        return
    wf = wave.open(path, 'rb')
    stream = conf.audio_player.open(
        format=conf.audio_player.get_format_from_width(wf.getsampwidth()),
        channels=wf.getnchannels(),
        rate=wf.getframerate(),
        output=True)
    try:
        print('Start Playing.')
        conf.isPlaying = True
        data = wf.readframes(conf.chunk)
        while data != b'':
            stream.write(data)
            data = wf.readframes(conf.chunk)
            # User interrupted
            while conf.Interrupted:
                time.sleep(1)
            # stop playing
            if conf.Stopped:
                break
            if conf.VOL_UP:
                conf.increaseVolume()
            elif conf.VOL_DOWN:
                conf.decreaseVolume()

    except KeyboardInterrupt:
        pass
    finally:
        stream.close()
        conf.audio_player.terminate()
        initializer.init_audio()
コード例 #6
0
def signup():
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រសមាជិក​"
    config.kargs['posts'] = userdb.select(config.kargs['dashboardPostLimit'])
    config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'],
                                               type="user")
    config.kargs['page'] = 1

    return template('dashboard/signup', data=config.kargs)
コード例 #7
0
def search(place):
  config.reset(settingdb.select())
  query = request.forms.getunicode('fquery')
  config.kargs['posts'] = postdb.search(query)
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['blogTitle'] = "ទំព័រ​ស្វែង​រក"

  if place == "backend":
    return template('dashboard/search', data=config.kargs)
  else:
    return template('search', data=config.kargs)
コード例 #8
0
ファイル: page.py プロジェクト: Sokhavuth/kwblog
def post(id):
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រ​ស្តាទិក"
    config.kargs['post'] = pagedb.select(1, id)
    config.kargs['posts'] = pagedb.select(config.kargs['frontPagePostLimit'])
    config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
    config.kargs['page'] = 1
    author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
    if author:
        config.kargs['showEdit'] = True

    return template('page', data=config.kargs)
コード例 #9
0
    def UpdateSettings(self, handler, query):
        config.reset()
        for section in ['Server', '_tivo_SD', '_tivo_HD']:
            new_setting = new_value = ' '
            for key in query:
                if key.startswith('opts.'):
                    data = query[key]
                    del query[key]
                    key = key[5:]
                    query[key] = data
                if key.startswith(section + '.'):
                    _, option = key.split('.')
                    if not config.config.has_section(section):
                        config.config.add_section(section)
                    if option == 'new__setting':
                        new_setting = query[key][0]
                    elif option == 'new__value':
                        new_value = query[key][0]
                    elif query[key][0] == ' ':
                        config.config.remove_option(section, option)
                    else:
                        config.config.set(section, option, query[key][0])
            if not (new_setting == ' ' and new_value == ' '):
                config.config.set(section, new_setting, new_value)

        sections = query['Section_Map'][0].split(']')
        sections.pop()  # last item is junk
        for section in sections:
            ID, name = section.split('|')
            if query[ID][0] == 'Delete_Me':
                config.config.remove_section(name)
                continue
            if query[ID][0] != name:
                config.config.remove_section(name)
                config.config.add_section(query[ID][0])
            for key in query:
                if key.startswith(ID + '.'):
                    _, option = key.split('.')
                    if option == 'new__setting':
                        new_setting = query[key][0]
                    elif option == 'new__value':
                        new_value = query[key][0]
                    elif query[key][0] == ' ':
                        config.config.remove_option(query[ID][0], option)
                    else:
                        config.config.set(query[ID][0], option, query[key][0])
            if not (new_setting == ' ' and new_value == ' '):
                config.config.set(query[ID][0], new_setting, new_value)
        if query['new_Section'][0] != ' ':
            config.config.add_section(query['new_Section'][0])
        config.write()

        handler.redir(SETTINGS_MSG, 5)
コード例 #10
0
def post(name):
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រសមាជិក"
    config.kargs['post'] = userdb.select(1, author=name)
    config.kargs['posts'] = userdb.select(config.kargs['authorPagePostLimit'])
    config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'], "user")
    config.kargs['page'] = 1
    author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
    if author:
        config.kargs['showEdit'] = True

    return template('user', data=config.kargs)
コード例 #11
0
ファイル: settings.py プロジェクト: WeekdayFiller/pytivo
    def UpdateSettings(self, handler, query):
        config.reset()
        for section in ['Server', '_tivo_SD', '_tivo_HD']:
            new_setting = new_value = ' '
            for key in query:
                if key.startswith('opts.'):
                    data = query[key]
                    del query[key]
                    key = key[5:]
                    query[key] = data
                if key.startswith(section + '.'):
                    _, option = key.split('.')
                    if not config.config.has_section(section):
                        config.config.add_section(section)
                    if option == 'new__setting':
                        new_setting = query[key][0]
                    elif option == 'new__value':
                        new_value = query[key][0]
                    elif query[key][0] == ' ':
                        config.config.remove_option(section, option)
                    else:
                        config.config.set(section, option, query[key][0])
            if not(new_setting == ' ' and new_value == ' '):
                config.config.set(section, new_setting, new_value)

        sections = query['Section_Map'][0].split(']')
        sections.pop() # last item is junk
        for section in sections:
            ID, name = section.split('|')
            if query[ID][0] == 'Delete_Me':
                config.config.remove_section(name)
                continue
            if query[ID][0] != name:
                config.config.remove_section(name)
                config.config.add_section(query[ID][0])
            for key in query:
                if key.startswith(ID + '.'):
                    _, option = key.split('.')
                    if option == 'new__setting':
                        new_setting = query[key][0]
                    elif option == 'new__value':
                        new_value = query[key][0]
                    elif query[key][0] == ' ':
                        config.config.remove_option(query[ID][0], option)
                    else:
                        config.config.set(query[ID][0], option, query[key][0])
            if not(new_setting == ' ' and new_value == ' '):
                config.config.set(query[ID][0], new_setting, new_value)
        if query['new_Section'][0] != ' ':
            config.config.add_section(query['new_Section'][0])
        config.write()

        handler.redir(SETTINGS_MSG, 5)
コード例 #12
0
ファイル: category.py プロジェクト: Sokhavuth/kwblog
def category(name):
  config.reset(settingdb.select())
  config.kargs['blogTitle'] = "ទំព័រ​ជំពូក"
  config.kargs['category'] = name
  config.kargs['posts'] = postdb.select(config.kargs['categoryPostLimit'], category=name)
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['page'] = 1
  author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
  if author:
    config.kargs['showEdit'] = True

  return template('categories', data=config.kargs)
    def _select_next_parameter(self):
        """Select the next parameter that should be tuned (and its predefined values).

        If no more parameters are available, hyper tuning will be disabled.
        """
        # reset all possible changes caused by the last parameter
        self._curr_value_index = 0
        cf.reset()

        if len(self._parameter_selection) > 0:
            self._current_parameter = self._parameter_selection.pop(0)
        else:
            self.finalize()
コード例 #14
0
ファイル: category.py プロジェクト: Sokhavuth/kwblog
def post():
  config.reset(settingdb.select())
  config.kargs['blogTitle'] = "ទំព័រ​ជំពូក"
  config.kargs['posts'] = categorydb.select(config.kargs['dashboardPostLimit'])
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['datetime'] = getTimeZone()
  config.kargs['page'] = 1
  author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
  if author:
    config.kargs['author'] = author
    config.kargs['showEdit'] = True

  return template('dashboard/category', data=config.kargs)
コード例 #15
0
 def test_set_methods(self):
     """ this tests all of the set methods since they need to work together """
     save_config_file = config.ConfigObject.CONFIG_FILE 
     
     # Test the default with no file is 'unittest'
     config.reset()
     config.ConfigObject.CONFIG_FILE = 'badfile.xxx'
     self.assertEqual(config.get_environment(), 'unittest')
     
     config.ConfigObject.CONFIG_FILE = save_config_file
     
     # test that if we the database name we have an unknown environmentwe
     config.reset()
     config.set_database_name(':memory:')
     self.assertEqual(config.get_environment(), '????')
     
     # test that if we the database name we have an unknown environmentwe
     config.reset()
     config.set_enviornment('test')
     self.assertTrue(config.get_database_name())
     
     # test that we have an instance and database
     config.reset()
     self.assertTrue(config.get_environment()) # All these values must be set... Can't test to what though
     self.assertTrue(config.get_database_name())
     self.assertTrue(config.get_database_instance())
     self.assertTrue(config.get_database())
コード例 #16
0
ファイル: category.py プロジェクト: Sokhavuth/kwblog
def edit(id):
  author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
  if ((author != "Guest") and categorydb.check(author)):
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រ​កែ​តំរូវ"
    config.kargs['posts'] = categorydb.select(config.kargs['dashboardPostLimit'])
    config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
    config.kargs['post'] = categorydb.select(1, id)
    config.kargs['edit'] = True
    config.kargs['postId'] = id
    config.kargs['page'] = 1
    return template('dashboard/category', data=config.kargs)
  
  redirect('/category')
コード例 #17
0
ファイル: settings.py プロジェクト: william40/pytivo
    def Settings(self, handler, query):
        # Read config file new each time in case there was any outside edits
        config.reset()

        shares_data = []
        for section in config.config.sections():
            if not (section.startswith('_tivo_')
                    or section.startswith('Server')):
                if (not (config.config.has_option(section, 'type')) or
                    config.config.get(section, 'type').lower() not in
                    ['settings', 'togo']):
                    shares_data.append((section,
                                        dict(config.config.items(section,
                                                                 raw=True))))

        cname = query['Container'][0].split('/')[0]
        t = Template(SETTINGS_TEMPLATE, filter=EncodeUnicode)
        t.container = cname
        t.quote = quote
        t.server_data = dict(config.config.items('Server', raw=True))
        t.server_known = buildhelp.getknown('server')
        if config.config.has_section('_tivo_HD'):
            t.hd_tivos_data = dict(config.config.items('_tivo_HD', raw=True))
        else:
            t.hd_tivos_data = {}
        t.hd_tivos_known = buildhelp.getknown('hd_tivos')
        if config.config.has_section('_tivo_SD'):
            t.sd_tivos_data = dict(config.config.items('_tivo_SD', raw=True))
        else:
            t.sd_tivos_data = {}
        t.sd_tivos_known = buildhelp.getknown('sd_tivos')
        t.shares_data = shares_data
        t.shares_known = buildhelp.getknown('shares')
        t.tivos_data = [(section, dict(config.config.items(section, raw=True)))
                        for section in config.config.sections()
                        if section.startswith('_tivo_')
                        and not section.startswith('_tivo_SD')
                        and not section.startswith('_tivo_HD')]
        t.tivos_known = buildhelp.getknown('tivos')
        t.help_list = buildhelp.gethelp()
        t.has_shutdown = hasattr(handler.server, 'shutdown')
        handler.send_response(200)
        handler.send_header('Content-Type', 'text/html; charset=utf-8')
        handler.send_header('Expires', '0')
        handler.end_headers()
        handler.wfile.write(t)
コード例 #18
0
def login():
    user = userdb.createTable()
    username = request.get_cookie("logged-in",
                                  secret=config.kargs['secretKey'])
    if not user:
        return template('dashboard/signup', data=config.kargs)
    elif username:
        config.reset(settingdb.select())
        config.kargs['author'] = username
        config.kargs['blogTitle'] = "ទំព័រ​គ្រប់គ្រង"
        config.kargs['datetime'] = getTimeZone()
        config.kargs['posts'] = postdb.select(
            config.kargs['dashboardPostLimit'])
        config.kargs['categories'] = categorydb.select(amount="all")
        config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
        config.kargs['page'] = 1
        return template('dashboard/home', data=config.kargs)
    else:
        return template('login', data=config.kargs)
コード例 #19
0
ファイル: experiment.py プロジェクト: davidjwu/mclass-sky
def experiment(n, iterations, X_testing, Y_testing, X_training, Y_training,
               center='ac', sample = 1, M=None):
    config.reset()

    testing=3
    matrix_of_weights = weights_matrix(n, iterations, X_training, Y_training, 
                                       center=center, sample=sample, M=M)
    matrix_of_accuracies = []
    
    for weights in matrix_of_weights:
        accuracies = []
        for weight in weights:
            accuracy = compute_accuracy(weight, X_testing, Y_testing)
            accuracies.append(accuracy)
        matrix_of_accuracies.append(accuracies)
    
    matrix_of_accuracies = np.array(matrix_of_accuracies)
    sum_of_accuracies = matrix_of_accuracies.sum(axis=0)
    average_accuracies = sum_of_accuracies/n
    return average_accuracies
コード例 #20
0
ファイル: settings.py プロジェクト: OmniWolfe/pytivo
    def UpdateSettings(self, handler, query):
        config.reset()
        for section in ['Server', '_tivo_SD', '_tivo_HD', '_tivo_4K']:
            self.each_section(query, section, section)

        sections = query['Section_Map'][0].split(']')[:-1]
        for section in sections:
            ID, name = section.split('|')
            if query[ID][0] == 'Delete_Me':
                config.config.remove_section(name)
                continue
            if query[ID][0] != name:
                config.config.remove_section(name)
                config.config.add_section(query[ID][0])
            self.each_section(query, ID, query[ID][0])

        if query['new_Section'][0] != ' ':
            config.config.add_section(query['new_Section'][0])
        config.write()

        handler.redir(SETTINGS_MSG, 5)
コード例 #21
0
ファイル: settings.py プロジェクト: hmblprogrammer/pytivo
    def UpdateSettings(self, handler, query):
        config.reset()
        for section in ['Server', '_tivo_SD', '_tivo_HD']:
            self.each_section(query, section, section)

        sections = query['Section_Map'][0].split(']')[:-1]
        for section in sections:
            ID, name = section.split('|')
            if query[ID][0] == 'Delete_Me':
                config.config.remove_section(name)
                continue
            if query[ID][0] != name:
                config.config.remove_section(name)
                config.config.add_section(query[ID][0])
            self.each_section(query, ID, query[ID][0])

        if query['new_Section'][0] != ' ':
            config.config.add_section(query['new_Section'][0])
        config.write()

        handler.redir(SETTINGS_MSG, 5)
コード例 #22
0
ファイル: admin.py プロジェクト: armooo/pytivo
 def Reset(self, handler, query):
     config.reset()
     handler.server.reset()
     if 'last_page' in query:
         last_page = query['last_page'][0]
     else:
         last_page = 'Admin'
     
     subcname = query['Container'][0]
     cname = subcname.split('/')[0]
     handler.send_response(200)
     handler.end_headers()
     t = Template(file=os.path.join(SCRIPTDIR,'templates', 'redirect.tmpl'))
     t.container = cname
     t.time = '3'
     t.url = '/TiVoConnect?Command='+ last_page +'&Container=' + cname
     t.text = '<h3>The pyTivo Server has been soft reset.</h3>  <br>pyTivo has reloaded the pyTivo.conf'+\
              'file and all changed should now be in effect. <br> The'+ \
              '<a href="/TiVoConnect?Command='+ last_page +'&Container='+ cname +'"> previous</a> page will reload in 3 seconds.'
     handler.wfile.write(t)
     debug.debug_write(__name__, debug.fn_attr(), ['The pyTivo Server has been soft reset.'])
     debug.print_conf(__name__, debug.fn_attr())
コード例 #23
0
    def Reset(self, handler, query):
        config.reset()
        handler.server.reset()
        if 'last_page' in query:
            last_page = query['last_page'][0]
        else:
            last_page = 'Admin'

        subcname = query['Container'][0]
        cname = subcname.split('/')[0]
        handler.send_response(200)
        handler.end_headers()
        t = Template(
            file=os.path.join(SCRIPTDIR, 'templates', 'redirect.tmpl'))
        t.container = cname
        t.time = '3'
        t.url = '/TiVoConnect?Command=' + last_page + '&Container=' + cname
        t.text = '<h3>The pyTivo Server has been soft reset.</h3>  <br>pyTivo has reloaded the pyTivo.conf'+\
                 'file and all changed should now be in effect. <br> The'+ \
                 '<a href="/TiVoConnect?Command='+ last_page +'&Container='+ cname +'"> previous</a> page will reload in 3 seconds.'
        handler.wfile.write(t)
        debug.debug_write(__name__, debug.fn_attr(),
                          ['The pyTivo Server has been soft reset.'])
        debug.print_conf(__name__, debug.fn_attr())
def check_passcd():
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    for j in range(3):
        GPIO.setup(Col[j], GPIO.OUT)
        GPIO.output(Col[j], 1)
    for i in range(4):
        GPIO.setup(Row[i], GPIO.IN, pull_up_down=GPIO.PUD_UP)
    enter = []
    star_list = []
    while True:
        time.sleep(0.2)
        for j in range(3):
            GPIO.output(Col[j], 0)
            for i in range(4):
                if (not GPIO.input(Row[i])):
                    if (Matrix[i][j] != '#'):
                        enter.append(Matrix[i][j])
                        if len(star_list) == 0:
                            star_list.append(Matrix[i][j])
                        else:
                            star_list[len(star_list) - 1] = '*'
                            star_list.append(Matrix[i][j])
                        print(star_list)
                        show_digit(star_list)
                    else:
                        print "enter"
                        print(enter)
                        passcode = config.reset()
                        print "passcode"
                        print(passcode)
                        print "Passcode matched?"
                        print(enter == passcode)
                        return (enter == passcode)

                    while (not GPIO.input(Row[i])):
                        pass

            GPIO.output(Col[j], 1)

    return False
コード例 #25
0
ファイル: settings.py プロジェクト: OmniWolfe/pytivo
 def Reset(self, handler, query):
     config.reset()
     handler.server.reset()
     handler.redir(RESET_MSG, 3)
     logging.getLogger('pyTivo.settings').info('pyTivo has been soft reset.')
コード例 #26
0
ファイル: api.py プロジェクト: Sakaki/nicoanimemanager
def resetconf(params):
    config.reset()

    return True, {"result" : "success"}
コード例 #27
0
ファイル: settings.py プロジェクト: hmblprogrammer/pytivo
 def Reset(self, handler, query):
     config.reset()
     handler.server.reset()
     handler.redir(RESET_MSG, 3)
     logging.getLogger('pyTivo.settings').info('pyTivo has been soft reset.')
コード例 #28
0
ファイル: ui_options.py プロジェクト: aomoriringo/crmsh
 def do_reset(self, context):
     "usage: reset"
     config.reset()
コード例 #29
0
ファイル: testmode.py プロジェクト: shanto268/hpwalk
def run():
    print("[Hiperwalk] Test mode!")

    cfg.TEST_MODE = 1
    devnull = open(os.devnull, 'w')

    orig_out = sys.stdout

    io.test_mode()
    writeInputs_TEST()
    returnValue = 1
    sys.stdout = devnull
    returnValue = subprocess.call(["neblina", "-l"],
                                  stdout=devnull,
                                  stderr=devnull)
    sys.stdout = orig_out
    if not returnValue:
        print("[Hiperwalk] Neblina installed.")
    else:
        print("[Hiperwalk] Neblina failed to execute.")
        exit(-1)

    cfg.reset()
    inputFile = str(os.path.abspath("coined1D_test.in"))
    sys.stdout = devnull
    returnValue = walks.walk(inputFile)
    sys.stdout = orig_out
    if returnValue:
        print("[Hiperwalk] DTQW on the line OK.")
    else:
        print("[Hiperwalk] DTQW on the line failed.")

    cfg.reset()
    inputFile = str(os.path.abspath("coined2D_test.in"))
    sys.stdout = devnull
    returnValue = walks.walk(inputFile)
    sys.stdout = orig_out
    if returnValue:
        print("[Hiperwalk] DTQW on the lattice OK.")
    else:
        print("[Hiperwalk] DTQW on the lattice failed.")

    cfg.reset()
    inputFile = str(os.path.abspath("staggered1D_test.in"))
    sys.stdout = devnull
    returnValue = walks.walk(inputFile)
    sys.stdout = orig_out
    if returnValue:
        print("[Hiperwalk] STAGGERED on the line OK.")
    else:
        print("[Hiperwalk] STAGGERED on the line failed.")

    cfg.reset()
    inputFile = str(os.path.abspath("staggered2D_test.in"))
    sys.stdout = devnull
    returnValue = walks.walk(inputFile)
    sys.stdout = orig_out
    if returnValue:
        print("[Hiperwalk] STAGGERED on the lattice OK.")
    else:
        print("[Hiperwalk] STAGGERED on the lattice failed.")

    cfg.reset()
    inputFile = str(os.path.abspath("custom_test.in"))
    sys.stdout = devnull
    returnValue = walks.walk(inputFile)
    sys.stdout = orig_out
    if returnValue:
        print("[Hiperwalk] CUSTOM WALK OK.")
    else:
        print("[Hiperwalk] CUSTOM WALK failed.")

    io.remnove_test_mode_folder()


#    print("[Hiperwalk] Files stored at %s/HIPERWALK_TEST_DIRECTORY"%(os.environ['HOME']))
コード例 #30
0
    def GetSettings(self, handler, query):
        # Read config file new each time in case there was any outside edits
        config.reset()

        shares_data = []
        for section in config.config.sections():
            if not section.startswith(('_tivo_', 'Server')):
                if (not (config.config.has_option(section, 'type'))
                        or config.config.get(section, 'type').lower()
                        not in ['settings', 'togo']):
                    shares_data.append(
                        (section, dict(config.config.items(section,
                                                           raw=True))))

        json_config = {}
        json_config['Server'] = {}
        json_config['TiVos'] = {}
        json_config['Shares'] = {}
        for section in config.config.sections():
            if section == 'Server':
                for name, value in config.config.items(section):
                    if name in {
                            'debug', 'nosettings', 'togo_save_txt',
                            'togo_decode', 'togo_sortable_names',
                            'tivolibre_upload', 'beta_tester', 'vrd_prompt',
                            'vrd_decrypt_qsf', 'vrd_delete_on_success'
                    }:
                        try:
                            json_config['Server'][
                                name] = config.config.getboolean(
                                    section, name)
                        except ValueError:
                            json_config['Server'][name] = value
                    else:
                        json_config['Server'][name] = value
            else:
                if section.startswith('_tivo_'):
                    json_config['TiVos'][section] = {}
                    for name, value in config.config.items(section):
                        if name in {'optres'}:
                            try:
                                json_config['TiVos'][section][
                                    name] = config.config.getboolean(
                                        section, name)
                            except ValueError:
                                json_config['TiVos'][section][name] = value
                        else:
                            json_config['TiVos'][section][name] = value
                else:
                    if (not (config.config.has_option(section, 'type'))
                            or config.config.get(section, 'type').lower()
                            not in ['settings', 'togo']):
                        json_config['Shares'][section] = {}
                        for name, value in config.config.items(section):
                            if name in {'force_alpha', 'force_ffmpeg'}:
                                try:
                                    json_config['Shares'][section][
                                        name] = config.config.getboolean(
                                            section, name)
                                except ValueError:
                                    json_config['Shares'][section][
                                        name] = value
                            else:
                                json_config['Shares'][section][name] = value

        handler.send_json(json.dumps(json_config))
コード例 #31
0
def reset():
	config.reset(config.pref_path())
コード例 #32
0
ファイル: ui_options.py プロジェクト: HideoYamauchi/crmsh
 def do_reset(self, context):
     "usage: reset"
     config.reset()
コード例 #33
0
ファイル: singleGeneModel.py プロジェクト: mossmatters/DPLSim
def penetrance(pars,logger=None):
	"""
	Given a simuPOP population, the relative risk (additive), the wild-type risk, and the number and cases and controls, build a case-control dataset in simuPOP format.
	DPL must be a list, even if there is only one locus.
	"""
	#DPL=["rs4491689", "rs2619939"]
	reppop = pars.pop.clone()
	loci = reppop.lociByNames(pars.DPL)
	#Set risks
	het_risk = pars.wtr*pars.GRR
	if pars.GRR > 1:
		hom_mut_risk = pars.wtr*pars.GRR*2
	else:
		hom_mut_risk = pars.wtr
	
	config.risks = [pars.wtr,het_risk,hom_mut_risk]
	config.numCases = pars.numCases
	config.numControls = pars.numControls
	
	reppop.evolve(
		matingScheme=RandomMating(
			ops=[
				MendelianGenoTransmitter(),
				# an individual will be discarded if _selectInds returns False
				PyOperator(func=_selectInds, param=loci)
			], 
			subPopSize=config.numCases + config.numControls
		),
		gen = 1
	)
	
	if logger:
		logger.info("Number of Wild Type Cases: %d" %config.NUM_WT_CASES)
		logger.info("Number of Mutant Controls: %d" %config.NUM_MUT_CONTROLS)
	
	config.SELECTED_CASE,config.SELECTED_CONTROL,config.DISCARDED_INDS,config.NUM_WT_CASES,config.NUM_MUT_CONTROLS = config.reset()
	return reppop
コード例 #34
0
def main(reset=False):
    if reset:
        config.reset()
        sys.exit()
コード例 #35
0
def main():
  config.reset(settingdb.select())
  config.kargs['posts'] = postdb.select(config.kargs['homePagePostLimit'])
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['page'] = 1
  return template('home', data=config.kargs)