def subcmd_get(self, argv): from submin.models import options self.sa.ensure_storage() if len(argv) == 1: try: value = options.value(argv[0]) except UnknownKeyError as e: print 'ERROR: %s does not exist' % argv[0] else: self._printkeyvalue(argv[0], value, len(argv[0])) else: all_options = sorted(options.options()) maxlen = 0 for arg in all_options: if len(arg[0]) > maxlen: maxlen = len(arg[0]) for arg in all_options: self._printkeyvalue(arg[0], arg[1], maxlen)
def testDefaults(self): expected = [(u'database_version', u'11'), (u'auth_type', u'sql'), (u'svn_dir', u'svn'), (u'git_dir', u'git'), (u'env_path', u'/bin:/usr/bin:/usr/local/bin:/opt/local/bin'), (u'dir_bin', u'static/bin'), (u'base_url_trac', u'/trac'), (u'base_url_git', u'/git'), (u'base_url_submin', u'/submin'), (u'http_vhost', u'darim'), (u'enabled_trac', u'no'), (u'trac_dir', u'trac'), (u'vcs_plugins', u'git,svn'), (u'base_url_svn', u'/svn')] unpredictable_keys = [u'session_salt'] c = c_config.c_config(self.sa, ['defaults']) c.run() observed = options.options() for idx, opt in enumerate(observed): key, value = opt if key in unpredictable_keys: del observed[idx] self.assertEquals(expected, observed)
def testDefaults(self): expected = [ (u'database_version', u'11'), (u'auth_type', u'sql'), (u'svn_dir', u'svn'), (u'git_dir', u'git'), (u'env_path', u'/bin:/usr/bin:/usr/local/bin:/opt/local/bin'), (u'dir_bin', u'static/bin'), (u'base_url_trac', u'/trac'), (u'base_url_git', u'/git'), (u'base_url_submin', u'/submin'), (u'http_vhost', u'darim'), (u'enabled_trac', u'no'), (u'trac_dir', u'trac'), (u'vcs_plugins', u'git,svn'), (u'base_url_svn', u'/svn') ] unpredictable_keys = [u'session_salt'] c = c_config.c_config(self.sa, ['defaults']) c.run() observed = options.options() for idx, opt in enumerate(observed): key, value = opt if key in unpredictable_keys: del observed[idx] self.assertEquals(expected, observed)
def diagnostics(): results = {} commit_email_from = options.value('commit_email_from', '') results['email_commit_set'] = commit_email_from != '' match = re.match('(.+) (<[^@>]+@[^@>]+\.[^@>]+>)', commit_email_from) results['email_commit_sane'] = match != None results['email_commit_current_value'] = commit_email_from smtp_from = options.value('smtp_from', '') results['email_from_set'] = smtp_from != '' match = re.match('(.+) (<[^@>]+@[^@>]+\.[^@>]+>)', smtp_from) results['email_from_sane'] = match != None results['email_from_current_value'] = smtp_from all_options = [x[0] for x in options.options()] sender = smtp_from if not results['email_from_set']: sender = 'root@localhost' sender = re.sub('.*<(.*)>.*', '\\1', sender) if 'smtp_hostname' in all_options: try: smtp.might_work(sender, '*****@*****.**') except SendEmailError as e: results['email_might_work_smtp_from'] = False results['email_might_work_smtp_from_msg'] = str(e) else: results['email_might_work_smtp_from'] = True else: try: local.might_work(sender, '*****@*****.**') except SendEmailError as e: results['email_might_work_smtp_from'] = False results['email_might_work_smtp_from_msg'] = str(e) else: results['email_might_work_smtp_from'] = True return add_labels(results, 'email_all', warnings, fails)
def testSetOption(self): options.set_value("foo", "bar") self.assertEquals(options.options(), [(u'git_dir', u'git'), (u'database_version', u'11'), (u'foo', u'bar')])
def testNoOptions(self): self.assertEquals(options.options(), [(u'git_dir', u'git'), (u'database_version', u'11')])