コード例 #1
0
    def test_invokes_action(self):
        dummy_calls = []

        def dummy_action(args):
            dummy_calls.append(True)

        with mock.patch.dict(actions.ACTIONS, {'foo': dummy_action}):
            actions.main(['foo'])
        self.assertEqual(dummy_calls, [True])
コード例 #2
0
    def test_failing_action(self):
        """Actions which traceback trigger action_fail() calls."""
        dummy_calls = []

        self.ch_core.hookenv.action_fail.side_effect = dummy_calls.append

        def dummy_action(args):
            raise ValueError('uh oh')

        with mock.patch.dict(actions.ACTIONS, {'foo': dummy_action}):
            actions.main(['foo'])
        self.assertEqual(dummy_calls, ['Action "foo" failed: "uh oh"'])
コード例 #3
0
def main():
    util.prepare_cache()
    config = config_factory.load()
    master = master_site(config, merge_small_groups=False)
    new_data = parse(open("input.txt").readlines())
    for (lang, site) in master.lang_sites.items():
        if new_data.get(lang, None):
            groups = site.groups + [new_data[lang]]

            lines = []
            for group in groups:
                lines.append("# %s" % group.title)
                for id in group.ids:
                    lines.append("%s" % id)
                lines.append("")
            with open("data/%s/data.txt" % site.lang, "w") as f:
                f.write('\n'.join(lines))
                print("Updated %s" % f.name)

    cleanup.main()
コード例 #4
0
ファイル: test_cleanup.py プロジェクト: jbretsch/pvrutils
    def cleanup(self, size, dirs=None):
        avail_space = cleanup.avail_space_in_mb(self.testdir)
        target_avail_space = avail_space + size
        sys.argv = ["cleanup.py", "-s", str(target_avail_space)]

        if dirs is None:
            sys.argv.append(self.testdir)
        else:
            for d in dirs:
                sys.argv.append(os.path.join(self.testdir, d))

        devnull = open(os.devnull, "w")
        with RedirectStdStreams(stdout=devnull, stderr=devnull):
            return cleanup.main()
コード例 #5
0
ファイル: scheduler.py プロジェクト: MarkusSpanring/hepDnn
def main():
    '''Takes paramters stored in 'fixed_params' (one at a time)
       and optimizes with spearmint for 'max_jobs' iterations.
       'fixed_params' contains a list of dictionaries.
       Each dictionary contains the paramters to fix.
       When 'fixed_params' is created with 
       'create_mask_list' variable reduction is performed
       from all features down to one.
    '''

    top_mask = '0x00c0'

    max_jobs = 25
    AMS_list = []
    RUN = True

    while RUN:
        fixed_params = create_mask_list(fixed_mask = top_mask)        
        # fixed_params = [{'nhid':6,'flag_reg':0x3},{'nhid':7,'flag_reg':0x3},{'nhid':8,'flag_reg':0x3},\
        #                 {'nhid':6,'flag_reg':0xb},{'nhid':7,'flag_reg':0xb},{'nhid':8,'flag_reg':0xb},\
        #                 False]                      
        print 'Using: ', fixed_params

        smry_list = []
        for fixed_param in fixed_params:
            if not fixed_param:
                return AMS_list
            try:
                smry_list.append(spear.main( max_jobs = max_jobs,
                                             expt_dir = os.environ['DNN_PATH'],
                                             fixed_param = fixed_param))
                cleanup.main()
            except KeyboardInterrupt:
                sys.exit()          


        top_mask = find_top_mask( smry_list )
コード例 #6
0
'''


def nL():
    print("\n")


print("Now starting scripts.")

retrieveData.main()
nL()

entertainments.main()
nL()

cleanup.main()
nL()

foods.main()
nL()

combine.main()
nL()

libraries.main()  #getting throttled, lost that dataset
nL()

parking.main()  #getting throttled, but still have that dataset
nL()

posnegScores.main()
コード例 #7
0
 def test_unknown_action(self):
     """Unknown actions aren't a traceback."""
     exit_string = actions.main(['foo'])
     self.assertEqual('Action "foo" undefined', exit_string)