def create_csv(project_id): config = Configs().find(project_id) arrays = Builds.select_values_from(config, None, config.builds()) folder = config.result_dir() writer = csv.writer(open(os.path.join(folder, project_id + '.csv'), 'w'), delimiter=',') writer.writerow(config.csv_keys()) writer.writerows(arrays)
def setup(request): configs = Configs() if (configs.is_empty()) : return render_to_response('analyse/hint.html', Context({}), context_instance = RequestContext(request)) current = configs.find(request.GET.get('id')) results = {"configs" : configs, 'current' : current} return render_to_response('analyse/setup.html', Context(results), context_instance = RequestContext(request))
def index(request): configs = Configs() if (configs.is_empty()) : return render_to_response('analyse/hint.html', Context({}), context_instance = RequestContext(request)) results = {'configs' : configs} return render_to_response('analyse/index.html', Context(results), context_instance = RequestContext(request))
def testToSelectValuesAsArrayByApplyingXPath(self): file = self.ccroot + '/log20091011173922Lbuild.1.xml' config = Configs().find('connectfour4') values = Build.select_values(file, config.csv_settings()) self.assertEquals('connectfour4', values[0]) self.assertEquals('1 minute(s) 0 second(s)', values[2]) self.assertEquals('build.1', values[1]) self.assertEquals(None, values[3])
def generate(request) : configs = Configs() if (configs.is_empty()) : return render_to_response('analyse/hint.html', Context({}), context_instance = RequestContext(request)) config = configs.find(request.POST['id']) over_all_result = {} Builds.create_builds(config, None, config.builds()) Build.analyse_all(config.id, over_all_result) Builds.create_csv(config.id) return redirect('index.html')
def show(request): configs = Configs() if (configs.is_empty()) : return render_to_response('analyse/hint.html', Context({}), context_instance = RequestContext(request)) project_id = request.GET['id'] config = configs.find(project_id) if not config.has_result() : return redirect('setup.html?id=' + urlquote(project_id)) over_all_result = { "project_id" : project_id, } Build.view_all(project_id, over_all_result) return render_to_response('analyse/show.html', Context(over_all_result), context_instance = RequestContext(request))
class ConfigsTests(TestCase): def setUp(self): self.configs_root = os.path.abspath(os.path.join(settings.PROJECT_DIR, 'analyse/tests/fixtures/config/')) self.configs = Configs(self.configs_root) def tearDown(self): pass def testShouldReturnTheConfigFilesUnderConfigsRoot(self): self.assertEquals(len(os.listdir(os.path.join(settings.PROJECT_DIR, 'analyse/tests/fixtures/config/'))), self.configs.size()) self.assertEquals(os.path.join(self.configs_root, 'ianalyse.cfg'), self.configs['ianalyse'].config_file) self.assertEquals(os.path.join(self.configs_root, 'no_days.cfg'), self.configs['no_days'].config_file) def testShouldReturnTheFirstConfigWhenNoIdProvided(self): self.assertEquals(os.path.join(self.configs_root, 'ianalyse.cfg'), self.configs.find(None).config_file) def testShouldReturnTheConfigEqualWithId(self): self.assertEquals(os.path.join(self.configs_root, 'no_days.cfg'), self.configs.find('no_days').config_file)
def setUp(self): self.configs_root = os.path.abspath(os.path.join(settings.PROJECT_DIR, 'analyse/tests/fixtures/config/')) self.configs = Configs(self.configs_root)
def testShouldReturnSpecificConfigFile(self): expected = os.path.abspath(os.path.join(settings.PROJECT_DIR, 'analyse/tests/fixtures/config/')) config = Configs(expected) self.assertEquals(expected, config.abspath())
def testShouldReturnTheAbsolutePathOfTheDefaultConfigFile(self): expected = os.path.abspath(os.path.join(settings.PROJECT_DIR, 'configs')) os.environ.pop("CONFIGS_DIR") config = Configs() self.assertEquals(expected, config.abspath())