コード例 #1
0
ファイル: manage.py プロジェクト: salam0smy/reviewboard
def main(settings, in_subprocess):
    if dirname(settings.__file__) == os.getcwd():
        sys.stderr.write("manage.py should not be run from within the "
                         "'reviewboard' Python package directory.\n")
        sys.stderr.write("Make sure to run this from the top of the "
                         "Review Board source tree.\n")
        sys.exit(1)

    if (len(sys.argv) > 1 and
        (sys.argv[1] == 'runserver' or sys.argv[1] == 'test')):
        if settings.DEBUG and not in_subprocess:
            sys.stderr.write('Running dependency checks (set DEBUG=False '
                             'to turn this off)...\n')
            check_dependencies(settings)
    else:
        # Some of our checks require access to django.conf.settings, so
        # tell Django about our settings.
        #
        # Initialize Review Board, so we're in a state ready to load
        # extensions and run management commands.
        from reviewboard import initialize
        initialize()

        include_enabled_extensions(settings)

    execute_from_command_line(sys.argv)
コード例 #2
0
def main(settings):
    if dirname(settings.__file__) == os.getcwd():
        sys.stderr.write("manage.py should not be run from within the "
                         "'reviewboard' Python package directory.\n")
        sys.stderr.write("Make sure to run this from the top of the "
                         "Review Board source tree.\n")
        sys.exit(1)

    if len(sys.argv) > 1 and \
       (sys.argv[1] == 'runserver' or sys.argv[1] == 'test'):
        if settings.DEBUG:
            # If DJANGO_SETTINGS_MODULE is in our environment, we're in
            # execute_from_command_line's sub-process.  It doesn't make sense
            # to do this check twice, so just return.
            if 'DJANGO_SETTINGS_MODULE' not in os.environ:
                sys.stderr.write('Running dependency checks (set DEBUG=False '
                                 'to turn this off)...\n')
                check_dependencies(settings)
    else:
        # Some of our checks require access to django.conf.settings, so
        # tell Django about our settings.
        #
        # Initialize Review Board, so we're in a state ready to load
        # extensions and run management commands.
        from reviewboard import initialize
        initialize()

        include_enabled_extensions(settings)

    execute_from_command_line(sys.argv)
コード例 #3
0
ファイル: manage.py プロジェクト: znick/reviewboard
def main(settings, in_subprocess):
    if dirname(settings.__file__) == os.getcwd():
        sys.stderr.write("manage.py should not be run from within the "
                         "'reviewboard' Python package directory.\n")
        sys.stderr.write("Make sure to run this from the top of the "
                         "Review Board source tree.\n")
        sys.exit(1)

    if (len(sys.argv) > 1
            and (sys.argv[1] == 'runserver' or sys.argv[1] == 'test')):
        if settings.DEBUG and not in_subprocess:
            sys.stderr.write('Running dependency checks (set DEBUG=False '
                             'to turn this off)...\n')
            check_dependencies(settings)
    else:
        # Some of our checks require access to django.conf.settings, so
        # tell Django about our settings.
        #
        # Initialize Review Board, so we're in a state ready to load
        # extensions and run management commands.
        from reviewboard import initialize
        initialize()

        include_enabled_extensions(settings)

    execute_from_command_line(sys.argv)
コード例 #4
0
ファイル: manage.py プロジェクト: darmhoo/reviewboard
def main(settings, in_subprocess):
    if dirname(settings.__file__) == os.getcwd():
        sys.stderr.write("manage.py should not be run from within the "
                         "'reviewboard' Python package directory.\n")
        sys.stderr.write("Make sure to run this from the top of the "
                         "Review Board source tree.\n")
        sys.exit(1)

    if (len(sys.argv) > 1 and
        (sys.argv[1] == 'runserver' or sys.argv[1] == 'test')):
        if settings.DEBUG and not in_subprocess:
            sys.stderr.write('Running dependency checks (set DEBUG=False '
                             'to turn this off)...\n')
            check_dependencies(settings)

        if sys.argv[1] == 'runserver':
            # Force using HTTP/1.1 for all responses, in order to work around
            # some browsers (Chrome) failing to consistently handle some
            # cache headers.
            simple_server.ServerHandler.http_version = '1.1'
    else:
        # Some of our checks require access to django.conf.settings, so
        # tell Django about our settings.
        #
        # Initialize Review Board, so we're in a state ready to load
        # extensions and run management commands.
        from reviewboard import initialize
        initialize()

        include_enabled_extensions(settings)

    execute_from_command_line(sys.argv)
コード例 #5
0
ファイル: testcase.py プロジェクト: qbig/reviewboard
    def setUp(self):
        super(TestCase, self).setUp()

        initialize()

        # Clear the cache so that previous tests don't impact this one.
        cache.clear()
コード例 #6
0
ファイル: manage.py プロジェクト: makhalin/reviewboard
def main(settings, in_subprocess):
    if dirname(settings.__file__) == os.getcwd():
        sys.stderr.write("manage.py should not be run from within the "
                         "'reviewboard' Python package directory.\n")
        sys.stderr.write("Make sure to run this from the top of the "
                         "Review Board source tree.\n")
        sys.exit(1)

    if (len(sys.argv) > 1
            and (sys.argv[1] == 'runserver' or sys.argv[1] == 'test')):
        if settings.DEBUG and not in_subprocess:
            sys.stderr.write('Running dependency checks (set DEBUG=False '
                             'to turn this off)...\n')
            check_dependencies(settings)

        if sys.argv[1] == 'runserver':
            # Force using HTTP/1.1 for all responses, in order to work around
            # some browsers (Chrome) failing to consistently handle some
            # cache headers.
            simple_server.ServerHandler.http_version = '1.1'
    else:
        # Some of our checks require access to django.conf.settings, so
        # tell Django about our settings.
        #
        # Initialize Review Board, so we're in a state ready to load
        # extensions and run management commands.
        from reviewboard import initialize
        initialize()

        include_enabled_extensions(settings)

    execute_from_command_line(sys.argv)
コード例 #7
0
ファイル: manage.py プロジェクト: javins/reviewboard
def main(settings):
    if dirname(settings.__file__) == os.getcwd():
        sys.stderr.write("manage.py should not be run from within the "
                         "'reviewboard' Python package directory.\n")
        sys.stderr.write("Make sure to run this from the top of the "
                         "Review Board source tree.\n")
        sys.exit(1)

    if len(sys.argv) > 1 and \
       (sys.argv[1] == 'runserver' or sys.argv[1] == 'test'):
        if settings.DEBUG:
            # If DJANGO_SETTINGS_MODULE is in our environment, we're in
            # execute_from_command_line's sub-process.  It doesn't make sense
            # to do this check twice, so just return.
            if 'DJANGO_SETTINGS_MODULE' not in os.environ:
                sys.stderr.write('Running dependency checks (set DEBUG=False '
                                 'to turn this off)...\n')
                check_dependencies(settings)
    else:
        # Some of our checks require access to django.conf.settings, so
        # tell Django about our settings.
        #
        # Initialize Review Board, so we're in a state ready to load
        # extensions and run management commands.
        from reviewboard import initialize
        initialize()

        include_enabled_extensions(settings)

    execute_from_command_line(sys.argv)
コード例 #8
0
ファイル: testcase.py プロジェクト: kuoxin/reviewboard
    def setUp(self):
        super(TestCase, self).setUp()

        initialize()

        # Clear the cache so that previous tests don't impact this one.
        cache.clear()
コード例 #9
0
    def main(self, options):
        """Main function for running unit tests for the extension.

        Args:
            options (argparse.Namespace):
                Options set from the arguments.

        Returns:
            int:
            The command's exit code.
        """
        os.environ[str('RB_TEST_MODULES')] = force_str(','.join(
            module_name for module_name in options.module_names))

        os.chdir(options.tree_root)
        os.environ[str('RB_RUNNING_TESTS')] = str('1')

        initialize()

        from reviewboard.test import RBTestRunner

        test_runner = RBTestRunner(test_packages=options.module_names,
                                   cover_packages=options.module_names,
                                   verbosity=1,
                                   needs_collect_static=False)
        failures = test_runner.run_tests(options.tests)

        if failures:
            return 1
        else:
            return 0
コード例 #10
0
ファイル: tests.py プロジェクト: phoenixmy/reviewboard
    def setUp(self):
        initialize()

        mail.outbox = []
        self.sender = '*****@*****.**'

        siteconfig = SiteConfiguration.objects.get_current()
        siteconfig.set("mail_send_new_user_mail", True)
        siteconfig.save()
        load_site_config()
コード例 #11
0
ファイル: tests.py プロジェクト: helloconan/reviewboard
    def setUp(self):
        initialize()

        mail.outbox = []
        self.sender = "*****@*****.**"

        siteconfig = SiteConfiguration.objects.get_current()
        siteconfig.set("mail_send_review_mail", True)
        siteconfig.set("mail_default_from", self.sender)
        siteconfig.save()
        load_site_config()
コード例 #12
0
ファイル: manage.py プロジェクト: vj-kestwal/reviewboard
def main(settings, in_subprocess):
    if dirname(settings.__file__) == os.getcwd():
        sys.stderr.write("manage.py should not be run from within the "
                         "'reviewboard' Python package directory.\n")
        sys.stderr.write("Make sure to run this from the top of the "
                         "Review Board source tree.\n")
        sys.exit(1)

    try:
        command_name = sys.argv[1]
    except IndexError:
        command_name = None

    if command_name in ('runserver', 'test'):
        if settings.DEBUG and not in_subprocess:
            sys.stderr.write('Running dependency checks (set DEBUG=False '
                             'to turn this off)...\n')
            check_dependencies(settings)

        if command_name == 'runserver':
            # Force using HTTP/1.1 for all responses, in order to work around
            # some browsers (Chrome) failing to consistently handle some
            # cache headers.
            simple_server.ServerHandler.http_version = '1.1'
    elif command_name == 'syncdb':
        sys.stderr.write('syncdb is no longer a valid command. Please use '
                         'createdb or upgrade.\n')
        return
    elif command_name == 'createdb':
        evolve_database(is_upgrade=False)
        return
    elif command_name not in ('evolve', 'syncdb', 'migrate'):
        # Some of our checks require access to django.conf.settings, so
        # tell Django about our settings.
        #
        # Initialize Review Board, so we're in a state ready to load
        # extensions and run management commands.
        #
        # Note that we don't do this for operations that may create the
        # database, since we don't want to run the risk of initialization
        # callbacks causing database creation to fail. (rb-site does not
        # initialize during its site creation process.)
        from reviewboard import initialize
        initialize()

        if command_name == 'upgrade':
            # We want to handle this command specially. This function will
            # perform its own command line executions, so bail after it's
            # done.
            upgrade_database()
            return

    execute_from_command_line(sys.argv)
コード例 #13
0
ファイル: alert.py プロジェクト: jjst/rbpriority
def main(in_subprocess):
    # Some of our checks require access to django.conf.settings, so
    # tell Django about our settings.
    #
    # Initialize Review Board, so we're in a state ready to load
    # extensions and run management commands.
    from reviewboard import settings, initialize
    initialize()

    include_enabled_extensions(settings)

    high_priority_reviews = get_high_priority_reviews()

    send_email_reminder(high_priority_reviews)
コード例 #14
0
ファイル: manage.py プロジェクト: chipx86/reviewboard
def main(settings, in_subprocess):
    if dirname(settings.__file__) == os.getcwd():
        sys.stderr.write("manage.py should not be run from within the "
                         "'reviewboard' Python package directory.\n")
        sys.stderr.write("Make sure to run this from the top of the "
                         "Review Board source tree.\n")
        sys.exit(1)

    try:
        command_name = sys.argv[1]
    except IndexError:
        command_name = None

    if command_name in ('runserver', 'test'):
        if settings.DEBUG and not in_subprocess:
            sys.stderr.write('Running dependency checks (set DEBUG=False '
                             'to turn this off)...\n')
            check_dependencies(settings)

        if command_name == 'runserver':
            # Force using HTTP/1.1 for all responses, in order to work around
            # some browsers (Chrome) failing to consistently handle some
            # cache headers.
            simple_server.ServerHandler.http_version = '1.1'
    elif command_name not in ('syncdb', 'migrate'):
        # Some of our checks require access to django.conf.settings, so
        # tell Django about our settings.
        #
        # Initialize Review Board, so we're in a state ready to load
        # extensions and run management commands.
        #
        # Note that we don't do this for operations that may create the
        # database, since we don't want to run the risk of initialization
        # callbacks causing database creation to fail. (rb-site does not
        # initialize during its site creation process.)
        from reviewboard import initialize
        initialize()

        if command_name == 'upgrade':
            # We want to handle this command specially. This function will
            # perform its own command line executions, so bail after it's
            # done.
            upgrade_database()
            return

        include_enabled_extensions(settings)

    execute_from_command_line(sys.argv)
コード例 #15
0
ファイル: tests.py プロジェクト: smorley/reviewboard
    def setUp(self):
        initialize()

        siteconfig = SiteConfiguration.objects.get_current()
        siteconfig.set("mail_send_review_mail", True)
        siteconfig.save()
        mail.outbox = []

        svn_repo_path = os.path.join(os.path.dirname(__file__), "../scmtools/testdata/svn_repo")
        self.repository = Repository(
            name="Subversion SVN", path="file://" + svn_repo_path, tool=Tool.objects.get(name="Subversion")
        )
        self.repository.save()

        self.client.login(username="******", password="******")
        self.user = User.objects.get(username="******")
コード例 #16
0
ファイル: middleware.py プロジェクト: ParikhKadam/reviewboard
    def middleware(request):
        """Ensure that Review Board initialization code has run.

        Args:
            request (django.http.HttpRequest):
                The HTTP request from the client.

        Returns:
            django.http.HttpResponse:
            The response object.
        """
        global _initialized

        if not _initialized:
            initialize()
            _initialized = True

        return get_response(request)
コード例 #17
0
    def setUp(self):
        super(BaseWebAPITestCase, self).setUp()

        initialize()

        self.siteconfig = SiteConfiguration.objects.get_current()
        self.siteconfig.set("mail_send_review_mail", False)
        self.siteconfig.set("auth_require_sitewide_login", False)
        self.siteconfig.save()
        self._saved_siteconfig_settings = self.siteconfig.settings.copy()

        mail.outbox = []

        fixtures = getattr(self, 'fixtures', [])

        if 'test_users' in fixtures:
            self.client.login(username="******", password="******")
            self.user = User.objects.get(username="******")

        self.base_url = 'http://testserver'
コード例 #18
0
ファイル: base.py プロジェクト: markrcote/reviewboard
    def setUp(self):
        super(BaseWebAPITestCase, self).setUp()

        initialize()

        self.siteconfig = SiteConfiguration.objects.get_current()
        self.siteconfig.set("mail_send_review_mail", False)
        self.siteconfig.set("auth_require_sitewide_login", False)
        self.siteconfig.save()
        self._saved_siteconfig_settings = self.siteconfig.settings.copy()

        mail.outbox = []

        fixtures = getattr(self, 'fixtures', [])

        if 'test_users' in fixtures:
            self.client.login(username="******", password="******")
            self.user = User.objects.get(username="******")

        self.base_url = 'http://testserver'
コード例 #19
0
def main():
    """Run the application."""
    os.environ.setdefault(str('DJANGO_SETTINGS_MODULE'),
                          str('reviewboard.settings'))

    if DEBUG:
        pid = os.getpid()
        log_filename = 'rbssh-%s.log' % pid

        if DEBUG_LOGDIR:
            log_path = os.path.join(DEBUG_LOGDIR, log_filename)
        else:
            log_path = log_filename

        logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(name)-18s %(levelname)-8s '
                            '%(message)s',
                            datefmt='%m-%d %H:%M',
                            filename=log_path,
                            filemode='w')

        logging.debug('%s' % sys.argv)
        logging.debug('PID %s' % pid)

    initialize()

    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)
    ch.setFormatter(logging.Formatter('%(message)s'))
    ch.addFilter(logging.Filter('root'))
    logging.getLogger('').addHandler(ch)

    path, port, command = parse_options(sys.argv[1:])

    if '://' not in path:
        path = 'ssh://' + path

    username, hostname = SCMTool.get_auth_from_uri(path, options.username)

    if username is None:
        username = getpass.getuser()

    logging.debug('!!! %s, %s, %s' % (hostname, username, command))

    client = SSHClient(namespace=options.local_site_name)
    client.set_missing_host_key_policy(paramiko.WarningPolicy())

    attempts = 0
    password = None

    key = client.get_user_key()

    while True:
        try:
            client.connect(hostname,
                           port,
                           username=username,
                           password=password,
                           pkey=key,
                           allow_agent=options.allow_agent)
            break
        except paramiko.AuthenticationException as e:
            if attempts == 3 or not sys.stdin.isatty():
                logging.error('Too many authentication failures for %s' %
                              username)
                sys.exit(1)

            attempts += 1
            password = getpass.getpass("%s@%s's password: " %
                                       (username, hostname))
        except paramiko.SSHException as e:
            logging.error('Error connecting to server: %s' % e)
            sys.exit(1)
        except Exception as e:
            logging.error('Unknown exception during connect: %s (%s)' %
                          (e, type(e)))
            sys.exit(1)

    transport = client.get_transport()
    channel = transport.open_session()

    if sys.platform in ('cygwin', 'win32'):
        logging.debug('!!! Using WindowsHandler')
        handler = WindowsHandler(channel)
    else:
        logging.debug('!!! Using PosixHandler')
        handler = PosixHandler(channel)

    if options.subsystem == 'sftp':
        logging.debug('!!! Invoking sftp subsystem')
        channel.invoke_subsystem('sftp')
        handler.transfer()
    elif command:
        logging.debug('!!! Sending command %s' % command)
        channel.exec_command(' '.join(command))
        handler.transfer()
    else:
        logging.debug('!!! Opening shell')
        channel.get_pty()
        channel.invoke_shell()
        handler.shell()

    logging.debug('!!! Done')
    status = channel.recv_exit_status()
    client.close()

    return status
コード例 #20
0
 def process_request(self, request):
     if not self._initialized:
         initialize()
         self._initialized = True
コード例 #21
0
ファイル: middleware.py プロジェクト: znick/reviewboard
 def process_request(self, request):
     if not self._initialized:
         initialize()
         self._initialized = True
コード例 #22
0
 def process_request(self, request):
     """Ensure that Review Board initialization code has run."""
     if not self._initialized:
         initialize()
         self._initialized = True
コード例 #23
0
ファイル: tests.py プロジェクト: priestd09/reviewboard
 def setUp(self):
     """Set up this test case."""
     initialize()
コード例 #24
0
ファイル: webapidocs.py プロジェクト: is00hcw/reviewboard
from reviewboard.webapi.resources import resources
from sphinx import addnodes
from sphinx.util import docname_join
from sphinx.util.compat import Directive


# Mapping of mimetypes to language names for syntax highlighting.
MIMETYPE_LANGUAGES = [
    ('application/json', 'javascript'),
    ('application/xml', 'xml'),
    ('text/x-patch', 'diff'),
]


# Initialize Review Board
initialize()


# Build the list of parents.
resources.root.get_url_patterns()


class ResourceNotFound(Exception):
    def __init__(self, directive, classname):
        self.classname = classname
        self.error_node = [
            directive.state_machine.reporter.error(
                str(self),
                line=directive.lineno)
        ]
コード例 #25
0
ファイル: tests.py プロジェクト: down-networks/reviewboard
 def setUp(self):
     initialize()
コード例 #26
0
ファイル: rbssh.py プロジェクト: CharanKamal-CLI/reviewboard
def main():
    """Run the application."""
    os.environ.setdefault(b'DJANGO_SETTINGS_MODULE', b'reviewboard.settings')

    if DEBUG:
        pid = os.getpid()
        log_filename = 'rbssh-%s.log' % pid

        if DEBUG_LOGDIR:
            log_path = os.path.join(DEBUG_LOGDIR, log_filename)
        else:
            log_path = log_filename

        logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(name)-18s %(levelname)-8s '
                                   '%(message)s',
                            datefmt='%m-%d %H:%M',
                            filename=log_path,
                            filemode='w')

        logging.debug('%s' % sys.argv)
        logging.debug('PID %s' % pid)

    initialize()

    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)
    ch.setFormatter(logging.Formatter('%(message)s'))
    ch.addFilter(logging.Filter('root'))
    logging.getLogger('').addHandler(ch)

    path, port, command = parse_options(sys.argv[1:])

    if '://' not in path:
        path = 'ssh://' + path

    username, hostname = SCMTool.get_auth_from_uri(path, options.username)

    if username is None:
        username = getpass.getuser()

    logging.debug('!!! %s, %s, %s' % (hostname, username, command))

    client = SSHClient(namespace=options.local_site_name)
    client.set_missing_host_key_policy(paramiko.WarningPolicy())

    attempts = 0
    password = None

    key = client.get_user_key()

    while True:
        try:
            client.connect(hostname, port, username=username,
                           password=password, pkey=key,
                           allow_agent=options.allow_agent)
            break
        except paramiko.AuthenticationException as e:
            if attempts == 3 or not sys.stdin.isatty():
                logging.error('Too many authentication failures for %s' %
                              username)
                sys.exit(1)

            attempts += 1
            password = getpass.getpass("%s@%s's password: " %
                                       (username, hostname))
        except paramiko.SSHException as e:
            logging.error('Error connecting to server: %s' % e)
            sys.exit(1)
        except Exception as e:
            logging.error('Unknown exception during connect: %s (%s)' %
                          (e, type(e)))
            sys.exit(1)

    transport = client.get_transport()
    channel = transport.open_session()

    if sys.platform in ('cygwin', 'win32'):
        logging.debug('!!! Using WindowsHandler')
        handler = WindowsHandler(channel)
    else:
        logging.debug('!!! Using PosixHandler')
        handler = PosixHandler(channel)

    if options.subsystem == 'sftp':
        logging.debug('!!! Invoking sftp subsystem')
        channel.invoke_subsystem('sftp')
        handler.transfer()
    elif command:
        logging.debug('!!! Sending command %s' % command)
        channel.exec_command(' '.join(command))
        handler.transfer()
    else:
        logging.debug('!!! Opening shell')
        channel.get_pty()
        channel.invoke_shell()
        handler.shell()

    logging.debug('!!! Done')
    status = channel.recv_exit_status()
    client.close()

    return status
コード例 #27
0
 def setUp(self):
     """Set up this test case."""
     initialize()
コード例 #28
0
ファイル: tests.py プロジェクト: yang/reviewboard
 def setUp(self):
     initialize()
     siteconfig = SiteConfiguration.objects.get_current()
     siteconfig.set("mail_send_review_mail", True)
     siteconfig.save()
     mail.outbox = []
コード例 #29
0
ファイル: webapidocs.py プロジェクト: sieverssj/reviewboard
from reviewboard.webapi.resources import root_resource
from sphinx import addnodes
from sphinx.util import docname_join
from sphinx.util.compat import Directive


# Mapping of mimetypes to language names for syntax highlighting.
MIMETYPE_LANGUAGES = [
    ('application/json', 'javascript'),
    ('application/xml', 'xml'),
    ('text/x-patch', 'diff'),
]


# Initialize Review Board
initialize()


# Build the list of parents.
root_resource.get_url_patterns()


class ResourceNotFound(Exception):
    def __init__(self, directive, classname):
        self.error_node = [
            directive.state_machine.reporter.error(
                'Unable to import the web API resource class "%s"' % classname,
                line=directive.lineno)
        ]

コード例 #30
0
ファイル: tests.py プロジェクト: halvorlu/reviewboard
 def setUp(self):
     initialize()
コード例 #31
0
 def process_request(self, request):
     """Ensure that Review Board initialization code has run."""
     if not self._initialized:
         initialize()
         self._initialized = True