Exemplo n.º 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])
Exemplo n.º 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"'])
Exemplo n.º 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()
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
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 )
'''


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()
Exemplo n.º 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)