示例#1
0
def run():
    # __file__ contains <submin-dir>/dispatch/cgirunner.py
    submin_www_dir = os.path.dirname(__file__)
    submin_dir = os.path.dirname(submin_www_dir)

    from submin.bootstrap import SubminInstallationCheck
    check = SubminInstallationCheck(submin_dir)
    if not check.ok:
        print "Status: 500\r\n\r\n",
        print check.error_page()
        sys.exit(0)

    from submin.models import storage
    storage.open()

    try:
        from submin.dispatch.cgirequest import CGIRequest
        from submin.dispatch.dispatcher import dispatcher

        req = CGIRequest()
        response = dispatcher(req)
        req.writeResponse(response)
    except Exception as e:
        import traceback
        trace = traceback.extract_tb(sys.exc_info()[2])
        list = traceback.format_list(trace)
        list.append(str(e))
        print "Status: 500\r\n\r\n",
        print ''.join(list)

    storage.close()
示例#2
0
def run():
	# __file__ contains <submin-dir>/dispatch/cgirunner.py
	submin_www_dir = os.path.dirname(__file__)
	submin_dir = os.path.dirname(submin_www_dir)

	from submin.bootstrap import SubminInstallationCheck
	check = SubminInstallationCheck(submin_dir)
	if not check.ok:
		print "Status: 500\r\n\r\n",
		print check.error_page()
		sys.exit(0)

	from submin.models import storage
	storage.open()

	try:
		from submin.dispatch.cgirequest import CGIRequest
		from submin.dispatch.dispatcher import dispatcher

		req = CGIRequest()
		response = dispatcher(req)
		req.writeResponse(response)
	except Exception as e:
		import traceback
		trace = traceback.extract_tb(sys.exc_info()[2])
		list = traceback.format_list(trace)
		list.append(str(e))
		print "Status: 500\r\n\r\n",
		print ''.join(list)

	storage.close()
示例#3
0
	def setUp(self):
		self.submin_env = tempfile.mkdtemp(prefix='submin-unittest')
		self.conf_dir = os.path.join(self.submin_env, 'conf')
		os.mkdir(self.conf_dir)
		self.authz_file = os.path.join(self.submin_env, 'conf', 'authz')

		mock_settings.base_dir = self.submin_env
		storage.open(mock_settings)
		storage.database_evolve()
		options.set_value('vcs_plugins', 'svn')
		options.set_value('svn_dir', 'svn')
		options.set_value('trac_dir', 'trac')
		options.set_value('svn_authz_file', 'conf/authz')
		options.set_value('enabled_trac', 'no')
		options.set_value('http_vhost', 'localhost')
		options.set_value('base_url_submin', '/submin')

		self.svn_dir = str(options.env_path('svn_dir'))
		self.trac_dir = str(options.env_path('trac_dir'))
		os.mkdir(self.svn_dir)
		os.mkdir(self.trac_dir)

		# now make some repositories
		self.repositories = [
			{'name': 'foo', 'status': 'ok', 'vcs': 'svn'},
			{'name': 'invalidperm', 'status': 'permission denied', 'vcs': 'svn'},
			{'name': 'invalidperm2', 'status': 'permission denied', 'vcs': 'svn'},
			{'name': 'example', 'status': 'ok', 'vcs': 'svn'},
			{'name': 'subdirs', 'status': 'ok', 'vcs': 'svn'},
		]
		self.has_invalidperm = False
		self.has_invalidperm2 = False
示例#4
0
	def setUp(self):
		self.submin_env = Path(tempfile.mkdtemp(prefix='submin-unittest'))
		conf_dir = self.submin_env + 'conf'
		os.mkdir(conf_dir)
		mock_settings.base_dir = self.submin_env
		storage.open(mock_settings)
		storage.database_evolve()
		self.sa = MagicMock()
		self.sa.env = self.submin_env
		self.saved_stdout, sys.stdout = sys.stdout, StringIO()
 def setUp(self):
     self.submin_env = Path(tempfile.mkdtemp(prefix='submin-unittest'))
     conf_dir = self.submin_env + 'conf'
     os.mkdir(conf_dir)
     mock_settings.base_dir = self.submin_env
     storage.open(mock_settings)
     storage.database_evolve()
     self.sa = MagicMock()
     self.sa.env = self.submin_env
     self.saved_stdout, sys.stdout = sys.stdout, StringIO()
示例#6
0
	def setUp(self):
		self.submin_env = Path(tempfile.mkdtemp(prefix='submin-unittest'))
		conf_dir = self.submin_env + 'conf'
		os.mkdir(conf_dir)
		mock_settings.base_dir = self.submin_env
		storage.open(mock_settings)
		storage.database_evolve()
		options.set_value('svn_authz_file', conf_dir + 'authz') # needed for export
		options.set_value('svn_dir', self.submin_env + 'svn') # needed for export
		options.set_value('git_dir', self.submin_env + 'git')
		options.set_value('vcs_plugins', 'svn, git')
示例#7
0
    def setUp(self):
        self.submin_env = tempfile.mkdtemp(prefix='submin-unittest')
        self.conf_dir = os.path.join(self.submin_env, 'conf')
        os.mkdir(self.conf_dir)
        self.authz_file = os.path.join(self.submin_env, 'conf', 'authz')

        mock_settings.base_dir = self.submin_env
        storage.open(mock_settings)
        storage.database_evolve()
        options.set_value('vcs_plugins', 'svn')
        options.set_value('svn_dir', 'svn')
        options.set_value('trac_dir', 'trac')
        options.set_value('svn_authz_file', 'conf/authz')
        options.set_value('enabled_trac', 'no')
        options.set_value('http_vhost', 'localhost')
        options.set_value('base_url_submin', '/submin')

        self.svn_dir = str(options.env_path('svn_dir'))
        self.trac_dir = str(options.env_path('trac_dir'))
        os.mkdir(self.svn_dir)
        os.mkdir(self.trac_dir)

        # now make some repositories
        self.repositories = [
            {
                'name': 'foo',
                'status': 'ok',
                'vcs': 'svn'
            },
            {
                'name': 'invalidperm',
                'status': 'permission denied',
                'vcs': 'svn'
            },
            {
                'name': 'invalidperm2',
                'status': 'permission denied',
                'vcs': 'svn'
            },
            {
                'name': 'example',
                'status': 'ok',
                'vcs': 'svn'
            },
            {
                'name': 'subdirs',
                'status': 'ok',
                'vcs': 'svn'
            },
        ]
        self.has_invalidperm = False
        self.has_invalidperm2 = False
示例#8
0
 def setUp(self):
     self.submin_env = Path(tempfile.mkdtemp(prefix='submin-unittest'))
     conf_dir = self.submin_env + 'conf'
     os.mkdir(conf_dir)
     mock_settings.base_dir = self.submin_env
     storage.open(mock_settings)
     storage.database_evolve()
     options.set_value('svn_authz_file',
                       conf_dir + 'authz')  # needed for export
     options.set_value('svn_dir',
                       self.submin_env + 'svn')  # needed for export
     options.set_value('git_dir', self.submin_env + 'git')
     options.set_value('vcs_plugins', 'svn, git')
示例#9
0
文件: users.py 项目: andy-deng/submin
 def setUp(self):
     self.submin_env = Path(tempfile.mkdtemp(prefix="submin-unittest"))
     conf_dir = self.submin_env + "conf"
     svn_dir = self.submin_env + "svn"
     os.mkdir(conf_dir)
     os.mkdir(svn_dir)
     mock_settings.base_dir = self.submin_env
     storage.open(mock_settings)
     storage.database_evolve()
     options.set_value("svn_authz_file", conf_dir + "authz")  # needed for export
     options.set_value("svn_dir", svn_dir)  # needed for export
     options.set_value("git_dir", self.submin_env + "git")
     options.set_value("vcs_plugins", "svn, git")
     self.tmp_dirs = []
     user.add("test", email="[email protected]", password="******")
     self.u = user.User("test")
示例#10
0
文件: trac.py 项目: andy-deng/submin
	def setUp(self):
		self.submin_env = tempfile.mkdtemp(prefix='submin-unittest')
		self.conf_dir = os.path.join(self.submin_env, 'conf')
		os.mkdir(self.conf_dir)
		mock_settings.base_dir = self.submin_env
		storage.open(mock_settings)
		storage.database_evolve()

		options.set_value('vcs_plugins', 'svn')
		options.set_value('svn_dir', 'svn')
		options.set_value('trac_dir', 'trac')
		options.set_value('svn_authz_file', 'conf/authz')
		options.set_value('enabled_trac', 'yes')

		self.svn_dir = str(options.env_path('svn_dir'))
		self.trac_dir = str(options.env_path('trac_dir'))
		os.mkdir(self.svn_dir)
		os.mkdir(self.trac_dir)
示例#11
0
    def setUp(self):
        self.submin_env = tempfile.mkdtemp(prefix='submin-unittest')
        self.conf_dir = os.path.join(self.submin_env, 'conf')
        os.mkdir(self.conf_dir)
        mock_settings.base_dir = self.submin_env
        storage.open(mock_settings)
        storage.database_evolve()

        options.set_value('vcs_plugins', 'svn')
        options.set_value('svn_dir', 'svn')
        options.set_value('trac_dir', 'trac')
        options.set_value('svn_authz_file', 'conf/authz')
        options.set_value('enabled_trac', 'yes')

        self.svn_dir = str(options.env_path('svn_dir'))
        self.trac_dir = str(options.env_path('trac_dir'))
        os.mkdir(self.svn_dir)
        os.mkdir(self.trac_dir)
def main():
    from sys import argv, path
    import os
    path.append('_SUBMIN_LIB_DIR_')
    interpreter = "perl"
    scriptname = 'commit-email.pl'
    scriptdir = os.path.dirname(argv[0])
    env = 'SUBMIN_LIB_DIR'
    if env in os.environ:
        path.append(os.environ[env])

    if len(argv) < 4:
        print "Usage: %s <configfile> <repository path> <revision>" % argv[0]
        return

    os.environ['SUBMIN_ENV'] = argv[1]
    repospath = argv[2]
    rev = argv[3]

    from submin.models import storage
    storage.open()

    from submin.models import options
    bindir = options.static_path("hooks") + 'svn'

    from submin.models import user
    userlist = [user.User(name) for name in user.list(user.FakeAdminUser())]

    n = buildNotifications(userlist)
    repos = os.path.basename(repospath)
    if repos not in n:
        print "no such repository"
        return

    mailer = bindir + scriptname
    for email in n[repos]:
        os.system("%s %s '%s' '%s' -s '[%s]' '%s'" %
                  (interpreter, mailer, repospath, rev, repos, email))
示例#13
0
def main():
	from sys import argv, path
	import os
	path.append('_SUBMIN_LIB_DIR_')
	interpreter = "perl"
	scriptname = 'commit-email.pl'
	scriptdir = os.path.dirname(argv[0])
	env = 'SUBMIN_LIB_DIR'
	if env in os.environ:
		path.append(os.environ[env])

	if len(argv) < 4:
		print "Usage: %s <configfile> <repository path> <revision>" % argv[0]
		return

	os.environ['SUBMIN_ENV'] = argv[1]
	repospath = argv[2]
	rev = argv[3]

	from submin.models import storage
	storage.open()

	from submin.models import options
	bindir = options.static_path("hooks") + 'svn'

	from submin.models import user
	userlist = [user.User(name) for name in user.list(user.FakeAdminUser())]

	n = buildNotifications(userlist)
	repos = os.path.basename(repospath)
	if repos not in n:
		print "no such repository"
		return

	mailer = bindir + scriptname
	for email in  n[repos]:
		os.system("%s %s '%s' '%s' -s '[%s]' '%s'" % (interpreter, mailer, repospath, rev, repos, email))
示例#14
0
 def setUp(self):
     storage.open(mock_settings)
     storage.database_evolve()
示例#15
0
	def setUp(self):
		storage.open(mock_settings)
		storage.database_evolve()
示例#16
0
	def __init__(self, *args, **kwargs):
		storage.open()
		self._config = self._get_config()

		super(SubminEnvironment, self).__init__(config=self._config, *args, **kwargs)
	def ensure_storage(self):
		if not self.storage_opened:
			storage.open()
			self.storage_opened = True