Exemplo n.º 1
0
def DeleteService(serviceName):
    """
        Base for DeleteService function , callable from other django application
    """
    try:
        settings=file(base_path+'/settings.py','r')
        settingFile=settings.read()
        settings.close()

        if settingFile.find(',\n    \'masterinterface.'+serviceName)>0:

            if os.path.exists(base_path+'/'+serviceName):
                shutil.rmtree(base_path+'/'+serviceName)

            newsettingFile=settingFile.replace(',\n    \'masterinterface.'+serviceName+'\'','')

            settingFile=file(base_path+'/settings.py','w')
            settingFile.write(newsettingFile)
            settingFile.close()

            UrlFile=file(base_path+'/urls.py','r')
            newUrlFile=UrlFile.read().replace(',\n    url(r\'^'+serviceName+'/\', include(\'masterinterface.'+serviceName+'.urls\'))','')
            UrlFile.close()
            UrlFile=file(base_path+'/urls.py','w')
            UrlFile.write(newUrlFile)
            UrlFile.close()
        else:
            return 0, "Service doesn't exist"

        sys.argv.append('syncdb')
        execute_manager(masterInterfaceSettings)
        return 1, "Delete done"
    except Exception, e:
        return 0, "Error on Delete"
Exemplo n.º 2
0
def run(settings):
    if not os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'third-party') in sys.path:
        sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'third-party'))
    if not os.path.dirname(os.path.dirname(os.path.abspath(__file__))) in sys.path:
        sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
    from django.core.management import execute_manager
    execute_manager(settings)
Exemplo n.º 3
0
def manage(*args):
    settings = utils.get_settings(apps=('django_extensions',))
    del settings.DEBUG
    config = utils.get_config_file()
    app = loadapp('config:%s' % config) # NOQA
    from django.core import management
    management.setup_environ = lambda *args: os.getcwd
    loadapp('config:%s' % config)
    from django.conf import settings as sets # NOQA
    args = args or sys.argv[1:]

    if not args:
        return sys.exit(management.execute_manager(settings))

    cmd = args[0]
    config = ConfigParser()
    config.read(os.path.expanduser('~/.djangodevkitrc'))
    try:
        alias = config.get('aliases', cmd)
    except:
        cmds = [args]
    else:
        sargs = ' '.join(args[1:])
        cmds = [a.replace('[]', sargs) for a in alias.split('\n') if a.strip()]
        cmds = [a.split() for a in cmds]
    for cmd in cmds:
        sys.argv[1:] = cmd
        management.execute_manager(settings)
Exemplo n.º 4
0
def init(reset):
    # first time setup (or re-setup)
    print "Initializing settings..."
    
    user_dir = os.path.expanduser("~/.openmdao/gui/")  # TODO: could put in a prefs file
    ensure_dir(user_dir)
    
    settings_file = "settings.py"
    database_file = user_dir+"mdaoproj.db"
    media_storage = user_dir+"media"
    
    if os.path.exists(settings_file):
        os.remove(settings_file)
    o = open(settings_file,"a") #open for append
    for line in open("settings.tmp"):
       line = line.replace("'NAME': 'mdaoproj.db'","'NAME': '"+database_file+"'")
       line = line.replace("MEDIA_ROOT = ''","MEDIA_ROOT = '"+media_storage+"'")
       o.write(line) 
    o.close()
    
    import settings
    print "MEDIA_ROOT=",settings.MEDIA_ROOT
    print "DATABASE=",settings.DATABASES['default']['NAME']
    
    print "Resetting project database..."
    if reset and os.path.exists(database_file):
        print "Deleting existing project database..."
        os.remove(database_file)
    from django.core.management import execute_manager
    execute_manager(settings,argv=[__file__,'syncdb'])
Exemplo n.º 5
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_manager'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.
        #
        # This must go before the imports.
        setup_environ(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_manager(settings)
Exemplo n.º 6
0
    def _start_server(self, host, port, threadnum):

        tmp_dir = kivy.kivy_home_dir
        pid_file = os.path.join(tmp_dir, 'wsgiserver.pid')

        import __main__
        project_dir = os.path.dirname(os.path.abspath(
                pj(__main__.__file__, '..')))
        sys.path.insert(1, pj(project_dir, 'ka-lite/kalite'))
        sys.path.insert(1, pj(project_dir, 'ka-lite'))
        sys.path.insert(1, pj(project_dir, 'ka-lite/python-packages'))
        os.chdir(pj(project_dir, 'ka-lite', 'kalite'))
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'kalite.settings')

        self.setup_chronograph()

        import settings
        from django.core.management import execute_manager
        execute_manager(settings, [
                'manage.py', 'runcherrypyserver',
                "host={}".format(host),
                "port={}".format(port),
                # "pidfile={}".format(pid_file),
                # 'daemonize=True',
                'daemonize=False',
                threadnum])
Exemplo n.º 7
0
    def _start_server(self, host, port):
        import __main__

        project_dir = os.path.dirname(os.path.abspath(pj(__main__.__file__, "..")))
        sys.path.insert(1, pj(project_dir, "ka-lite/kalite"))
        sys.path.insert(1, pj(project_dir, "ka-lite/python-packages"))
        os.chdir(pj(project_dir, "ka-lite", "kalite"))
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

        self.setup_chronograph()

        import settings
        from django.core.management import execute_manager

        execute_manager(
            settings,
            [
                "manage.py",
                "runcherrypyserver",
                "host={}".format(host),
                "port={}".format(port),
                "daemonize=False",
                "threads=3",
            ],
        )
Exemplo n.º 8
0
	def runNginxServer(self):
		from django.core.servers.fastcgi import runfastcgi
		from django.core.management import setup_environ
		from mysite import settings
		os.chdir("%s/nginx"%self.p)
		fname="conf/site.conf"
		f=file(fname, "w+")
		confStr=nginxConf%{"PORT":self.port, "FCGI_PORT":self.fcgiPort}
		f.write(confStr)
		f.close()
		if os.name=='posix': 
			os.system("""./nginx""")
		else: #'nt', windows
			os.system("""nginx.exe -s stop""")
			os.system("""start nginx.exe""")
		os.chdir(self.p)
		#print "startup fcgi module ..."
		if os.name=='posix': 
			setup_environ(settings)
			runfastcgi(method="threaded", maxrequests=500, protocol="fcgi", host="localhost", port=self.fcgiPort)
		else: #runfcgi method=threaded host=localhost port=10026
			from django.core.management import execute_manager
			sys.argv.append("runfcgi") 
			sys.argv.append("method=thread") 
			sys.argv.append("host=localhost") 
			sys.argv.append("port=%s"%self.fcgiPort)
			execute_manager(settings)
Exemplo n.º 9
0
Arquivo: manage.py Projeto: Foxas/369
def main():
    try:
        management.execute_manager(settings)
    except KeyboardInterrupt:
        print ""
        print "Exiting script."
        sys.exit(0)
Exemplo n.º 10
0
def main():
    if len(sys.argv) < 2 and not in_armstrong_project():
        usage()
        sys.exit(0)

    if len(sys.argv) >= 2:
        subcommand = sys.argv[1]
        if subcommand in ARMSTRONG_COMMANDS:
            sys.exit(ARMSTRONG_COMMANDS[subcommand]())

    # are we in an armstrong project?
    if in_armstrong_project():
        # Make sure the current working dir is always in the path as the first
        # element.  Initial tests on a Homebrew Python installation result in
        # this not being the case.
        if CWD not in sys.path:
            sys.path.insert(0, CWD)

        settings_module = "config.development"
        if "--production" in sys.argv:
            settings_module = "config.production"
            del sys.argv[sys.argv["--production"]]

        try:
            __import__(settings_module, globals(), locals())
            settings = sys.modules[settings_module]
        except ImportError, e:
            sys.stderr.write("Unable to import %s: %s" % (settings_module, e))
            sys.exit(1)
        from django.core.management import execute_manager
        execute_manager(settings)
Exemplo n.º 11
0
def start (args):
    
    # if a specific conf has been provided (which it
    # will be), if we're inside the django reloaded
    if "RAPIDSMS_INI" in os.environ:
        ini = os.environ["RAPIDSMS_INI"]
    
    # use a local ini (for development)
    # if one exists, to avoid everyone
    # having their own rapidsms.ini
    elif os.path.isfile("local.ini"):
        ini = "local.ini"
    
    # otherwise, fall back
    else: ini = "rapidsms.ini"


    # add the ini path to the environment, so we can
    # access it globally, including any subprocesses
    # spawned by django
    os.environ["RAPIDSMS_INI"] = ini

    # read the config, which is shared
    # between the back and frontend
    conf = Config(ini)
    
    # import the webui settings, which builds the django
    # config from rapidsms.config, in a round-about way.
    # can't do it until env[RAPIDSMS_INI] is defined
    from rapidsms.webui import settings

    # whatever we're doing, we'll need to call
    # django's setup_environ, to configure the ORM
    os.environ["DJANGO_SETTINGS_MODULE"] = "rapidsms.webui.settings"
    from django.core.management import setup_environ, execute_manager
    setup_environ(settings)

    # if one or more arguments were passed, we're
    # starting up django -- copied from manage.py
    if len(args) > 1:
        execute_manager(settings)
    
    # no arguments passed, so perform
    # the default action: START RAPIDSMS
    else:
        router = Router()
        router.set_logger(conf["log"]["level"], conf["log"]["file"])
        router.info("RapidSMS Server started up")
        
        # add each application from conf
        for app_conf in conf["rapidsms"]["apps"]:
            router.add_app(app_conf)

        # add each backend from conf
        for backend_conf in conf["rapidsms"]["backends"]:
            router.add_backend(backend_conf)

        # wait for incoming messages
        router.start()
Exemplo n.º 12
0
 def run(self):
     os.chdir(self.testproj_dir)
     sys.path.append(self.testproj_dir)
     os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
     settings_file = os.environ['DJANGO_SETTINGS_MODULE']
     settings_mod = __import__(settings_file, {}, {}, [''])
     from django.core.management import execute_manager
     execute_manager(settings_mod, argv=[__file__, "test"])
Exemplo n.º 13
0
def main():
  HERE = os.path.abspath(__file__)
  HERE = os.path.join(os.path.dirname(HERE), '..')
  HERE = os.path.normpath(HERE)

  sys.path = [HERE] + sys.path

  execute_manager(settings)
Exemplo n.º 14
0
def assist_the_regional_manager(args):
    if not os.path.exists(args.settings_file):
        sys.stderr.write(ERRORS['nofile'] % args.settings_file)
        sys.exit(1)
    from django.core.management import execute_manager
    settings = load_settings_file(args.settings_file)
    mgmt_argv = [str(__file__),] + args.MGMT_CMD + args.MGMT_ARGS
    execute_manager(settings, argv=mgmt_argv)
Exemplo n.º 15
0
def manage(config):
    """django's manage wrapper to take care of the configuration"""
    from pytheon.utils import Config
    config = Config.from_file(config)
    config = dict(config['app:main'].items())
    settings = django_settings(config)
    from django.core.management import execute_manager
    execute_manager(settings)
Exemplo n.º 16
0
        def runSimpleServer(self):
                '''
                Django 内置服务器运行
                '''
#                print "runSimpleServer"
                from django.core.management import execute_manager
                from mysite import settings 
                execute_manager(settings, [self.p+'/mysite/manage.py', 'runserver', self.address])
Exemplo n.º 17
0
def rule_with_an_iron_fist(args):
    settings_file = load_with_label(args.LABEL)
    if not os.path.exists(settings_file):
        sys.stderr.write(ERRORS['nofile'] % settings_file)
        sys.exit(1)
    settings = load_settings_file(settings_file)
    from django.core.management import execute_manager
    mgmt_argv = [str(__file__),] + args.MGMT_CMD + args.MGMT_ARGS
    execute_manager(settings, argv=mgmt_argv)
Exemplo n.º 18
0
def main():

    # Import test settings
    from django_banking import test_settings as settings 
    setup_environ(settings)

    # Use Django's Execute manager to run the tests
    sys.argv = [sys.argv[0],'test', 'django_banking']
    execute_manager(settings)
Exemplo n.º 19
0
def manage_15orless():
    from django.core.management import execute_manager
    try:
        import settings # Assumed to be in the same directory.
    except ImportError:
        sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
        sys.exit(1)

    execute_manager(settings)
Exemplo n.º 20
0
def start(args):
    # if a specific conf has been provided (which it
    # will be), if we're inside the django reloaded
    if "RAPIDSMS_INI" in os.environ:
        ini = os.environ["RAPIDSMS_INI"]

    # use a local ini (for development)
    # if one exists, to avoid everyone
    # having their own rapidsms.ini
    elif os.path.isfile("local.ini"):
        ini = "local.ini"

    # otherwise, fall back
    else:
        ini = "rapidsms.ini"

    # add the ini path to the environment, so we can
    # access it globally, including any subprocesses
    # spawned by django
    os.environ["RAPIDSMS_INI"] = ini

    # read the config, which is shared
    # between the back and frontend
    conf = Config(ini)

    # if we found a config ini, try to configure Django
    if conf.sources:

        # import the webui settings, which builds the django
        # config from rapidsms.config, in a round-about way.
        # can't do it until env[RAPIDSMS_INI] is defined
        from rapidsms.webui import settings

        import_local_settings(settings, ini)

        # whatever we're doing, we'll need to call
        # django's setup_environ, to configure the ORM
        os.environ["DJANGO_SETTINGS_MODULE"] = "rapidsms.webui.settings"
        from django.core.management import setup_environ, execute_manager

        setup_environ(settings)
    else:
        settings = None

    # if one or more arguments were passed, we're
    # starting up django -- copied from manage.py
    if len(args) < 2:
        print "Commands: route, startproject <name>, startapp <name>"
        sys.exit(1)

    if hasattr(Manager, args[1]):
        handler = getattr(Manager(), args[1])
        handler(conf, *args[2:])
    elif settings:
        # none of the commands were recognized,
        # so hand off to Django
        execute_manager(settings)
Exemplo n.º 21
0
def manage_global():
    try:
        from qualitio import settings
    except:
        sys.stderr.write(import_error_message)

    from django.core.management import execute_manager

    execute_manager(settings)
Exemplo n.º 22
0
 def SvcDoRun(self):
     self.ReportServiceStatus(win32service.SERVICE_START_PENDING)
     try:
         self.ReportServiceStatus(win32service.SERVICE_RUNNING)
         from django.core.management import execute_manager
         execute_manager(settings)
         win32event.WaitForSingleObject(self.stop_event, win32event.INFINITE)
     except Exception, ex:
         self.log('Exception: %s' % ex)
         self.SvcStop()
Exemplo n.º 23
0
def main():
    # Sync db
    #execute_manager(settings, argv="syncdb")
    execute_manager(settings, argv=[__file__, "syncdb"])
    
    # Populate initial branch
    for name, path in (("trunk","trunk/l10n-kde4"), ("stable", "branches/stable/l10n-kde4")):
        Branch.objects.get_or_create(name=name, path=path)

    print
    print "Now, you can synchronise your database with 'py10n -sg' for GUI and 'py10n -sd' for docs"
Exemplo n.º 24
0
 def run(self):
     this_dir = os.getcwd()
     testproj_dir = os.path.join(this_dir, "test_project")
     os.chdir(testproj_dir)
     sys.path.append(testproj_dir)
     from django.core.management import execute_manager
     os.environ["DJANGO_SETTINGS_MODULE"] = 'test_project.settings'
     settings_file = os.environ["DJANGO_SETTINGS_MODULE"]
     settings_mod = __import__(settings_file, {}, {}, [''])
     execute_manager(settings_mod, argv=[
         __file__, "test", "eav_forms"])
     os.chdir(this_dir)
Exemplo n.º 25
0
def manage(*args):
    settings = utils.get_settings(apps=('django_extensions',))
    del settings.DEBUG
    config = utils.get_config_file()
    app = loadapp('config:%s' % config)
    from django.core import management
    management.setup_environ = lambda *args: os.getcwd
    loadapp('config:%s' % config)
    from django.core.management import execute_manager
    from django.conf import settings as sets
    sys.argv[1:1] = args
    management.execute_manager(settings)
Exemplo n.º 26
0
def main():

    if django.VERSION[0] >= 1 and django.VERSION[1] >= 5:

        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "appomatic.settings")
        from django.core.management import execute_from_command_line

        execute_from_command_line(sys.argv)
    else:
        from django.core.management import execute_manager

        execute_manager(settings)
Exemplo n.º 27
0
 def run(self):
     this_dir = os.getcwd()
     testproj_dir = os.path.join(this_dir, "testproj")
     os.chdir(testproj_dir)
     sys.path.insert(0, testproj_dir)
     from django.core.management import execute_manager
     os.environ["DJANGO_SETTINGS_MODULE"] = os.environ.get(
                     "DJANGO_SETTINGS_MODULE", "settings")
     settings_file = os.environ["DJANGO_SETTINGS_MODULE"]
     settings_mod = __import__(settings_file, {}, {}, [''])
     execute_manager(settings_mod, argv=[__file__, "test"])
     os.chdir(this_dir)
Exemplo n.º 28
0
 def run(self):
     this_dir = os.getcwd()
     testproj_dir = os.path.join(this_dir, 'risiko')
     os.chdir(testproj_dir)
     sys.path.append(testproj_dir)
     from django.core.management import execute_manager
     os.environ['DJANGO_SETTINGS_MODULE'] = os.environ.get(
         'DJANGO_SETTINGS_MODULE', 'settings')
     settings_file = os.environ['DJANGO_SETTINGS_MODULE']
     settings_mod = __import__(settings_file, {}, {}, [''])
     execute_manager(settings_mod, argv=[
         __file__, 'test'])
     os.chdir(this_dir)
Exemplo n.º 29
0
def main():
    parser = Bcfg2.Options.get_parser()
    parser.add_options([
        Bcfg2.Options.PositionalArgument('django_command', nargs='*')])
    parser.parse()

    if django.VERSION[0] == 1 and django.VERSION[1] >= 6:
        from django.core.management import execute_from_command_line
        execute_from_command_line(
            sys.argv[:1] + Bcfg2.Options.setup.django_command)
    else:
        from django.core.management import execute_manager
        execute_manager(Bcfg2.DBSettings.settings)
Exemplo n.º 30
0
def django_run_server (project, logger):
    django_module = project.get_mandatory_property("django_module")
    
    logger.info("Running Django development server for %s", django_module)
    
    module = "%s.settings" % django_module
    sys.path.append(project.expand_path("$dir_source_main_python"))
    try:
        __import__(module)
    except ImportError as e:
        raise PythonbuilderException("Missing settings module: " + str(e))
    
    execute_manager(sys.modules[module], ["", "runserver"])
Exemplo n.º 31
0
#!/usr/bin/env python
import sys, os

current_dir = os.path.dirname(os.path.abspath(__file__))

sys.path.extend([
    os.path.join(current_dir, 'packages'),
])

from django.core.management import execute_manager
import imp
try:
    import config.local  # Assumed to be in the config directory.
except ImportError:
    sys.stderr.write(
        "Error: Can't find the file 'config/local.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n"
        % __file__)
    sys.exit(1)

import config.local

if __name__ == "__main__":
    execute_manager(config.local)
Exemplo n.º 32
0
#!/usr/bin/env python

from django.core.management import execute_manager
try:
    import albatross.ms.settings
except ImportError:
    import sys
    sys.stderr.write(
        "Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n"
        % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(albatross.ms.settings)
Exemplo n.º 33
0
#!/usr/bin/env python
from django.core.management import execute_manager
import imp, os
try:
    imp.find_module('settings')  # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write(
        "Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n"
        % __file__)
    sys.exit(1)

import settings.development

if __name__ == "__main__":
    execute_manager(settings.development)
Exemplo n.º 34
0
def legacy_main():
    find_sources()
    settings_module = "lava_server.settings.development"
    settings = __import__(settings_module, fromlist=[''])
    from django.core.management import execute_manager
    execute_manager(settings)
Exemplo n.º 35
0
#!/usr/bin/env python
from django.core.management import execute_manager
try:
    import admin_settings # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(admin_settings)
Exemplo n.º 36
0
setup_environ(settings_mod)

prev_sys_path = list(sys.path)

# define paths to work on
BASE_PATH = abspath(join(abspath(dirname(__file__)), '..'))
LIB_PATH = join(BASE_PATH, 'env', 'lib', 'python2.6')
SITE_PACKAGES_PATH = join(LIB_PATH, 'site-packages')

# add libs and pluggables to our python path
for d in (LIB_PATH, SITE_PACKAGES_PATH):
    path = addsitedir(d, set())
    if path:
    	    sys.path = list(path) + sys.path

# Reorder sys.path so new directories at the front.
new_sys_path = []
for item in list(sys.path):
	if item not in prev_sys_path:
		new_sys_path.append(item)
		sys.path.remove(item)
sys.path[:0] = new_sys_path

# make sure that project's manage.py command creates new apps inside the right directory
cmds = get_commands()
cmds['startapp'] = ProjectCommand(settings.PATH)

if __name__ == '__main__':
    #execute_from_command_line()
    execute_manager(settings_mod)
Exemplo n.º 37
0
        def runSimpleServer(self):
#                print "runSimpleServer"
                from django.core.management import execute_manager
                from mysite import settings 
                execute_manager(settings, [self.p+'/mysite/manage.py', 'runserver', self.address])
Exemplo n.º 38
0
)

SQLITE_DB_ENGINE = "sqlite3"

if __name__ == "__main__":
    if settings.DATABASE_ENGINE == SQLITE_DB_ENGINE and os.path.exists(
            settings.DATABASE_NAME):
        print "Removing " + settings.DATABASE_NAME
        os.remove(settings.DATABASE_NAME)
    else:
        from django.db import connection
        cursor = connection.cursor()
        cursor.execute("drop database if exists %s; create database %s;" %
                       (settings.DATABASE_NAME, settings.DATABASE_NAME))

    execute_manager(settings, ["", "syncdb"])
    print "Creating categories"
    for category_name in CATEGORIES:
        category = Category(name=category_name)
        category.save()
    print Category.objects.all()

    print "Creating ratings"
    for rating_value in RATINGS:
        rating = Rating(value=rating_value)
        rating.save()
    print Rating.objects.all()

    print "Creating labels"
    for label_name in LABELS:
        label = Label(name=label_name)
Exemplo n.º 39
0
#!/usr/bin/env python
from django.core.management import execute_manager
try:
    import settings.local  # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write(
        "Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n"
        % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(settings.local)
Exemplo n.º 40
0
#!/usr/bin/env python
import os
import sys
import django
import Bcfg2.Options
import Bcfg2.DBSettings

try:
    import Bcfg2.Server.models
except ImportError:
    pass

parser = Bcfg2.Options.get_parser()
parser.add_options([Bcfg2.Options.PositionalArgument('django_command', nargs='*')])
parser.parse()

if __name__ == "__main__":
    if django.VERSION[0] == 1 and django.VERSION[1] >= 6:
        from django.core.management import execute_from_command_line
        execute_from_command_line(sys.argv[:1] + Bcfg2.Options.setup.django_command)
    else:
        from django.core.management import execute_manager
        execute_manager(Bcfg2.DBSettings.settings)
Exemplo n.º 41
0
#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-
from os import path
import shutil, sys, subprocess

PROJECT_ROOT = path.dirname(path.abspath(path.dirname(__file__)))

sys.path.insert(0, PROJECT_ROOT)

# run django
from django.core.management import execute_manager
try:
    import tests.settings
except ImportError:
    import sys
    sys.stderr.write(
        "Error: Can't find the file 'settings.py' in the directory")
    sys.exit(1)

if __name__ == "__main__":
    if len(sys.argv) == 1:
        sys.argv += ['test'] + list(tests.settings.PROJECT_APPS)
    execute_manager(tests.settings)
Exemplo n.º 42
0
#!/usr/bin/env python
from django.core.management import execute_manager

try:
    import settings  # Assumed to be in the same directory.
except ImportError:
    import sys

    sys.stderr.write(
        "Error: Can't find the file 'settings.py' in the directory containing %r. "
        "It appears you've customized things.\nYou'll have to run django-admin.py,"
        " passing it your settings module.\n" % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(settings, argv=["manage.py", "runserver", "9000"])
Exemplo n.º 43
0
#!/usr/bin/env python
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'
current_dirname = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(current_dirname, '..'))
sys.path.insert(0, os.path.join(current_dirname, '../..'))

from django.core.management import execute_manager

try:
    import test_settings  # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write(
        "Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n"
        % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(test_settings)
Exemplo n.º 44
0
def main():
    execute_manager(settings)
Exemplo n.º 45
0
#!/usr/bin/env /opt/python2.7/bin/python
from django.core.management import execute_manager
import imp
try:
    imp.find_module(
        'settings_production')  # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write(
        "Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n"
        % __file__)
    sys.exit(1)

import settings_production

if __name__ == "__main__":
    execute_manager(settings_production)
Exemplo n.º 46
0
#!/usr/bin/python
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = "levels.settings"
import django

from django.core.management import execute_manager
import levels.settings # Assumed to be in the same directory.

if __name__ == "__main__":
    execute_manager(levels.settings) 

Exemplo n.º 47
0
def start_server(run_browser, interface=None):
    pid_path = os.path.join(settings.STATE_ROOT, "server.pid")
    if os.path.exists(pid_path):
        server_pid = int(open(pid_path).read())
        pid_found = False
        try:
            os.kill(server_pid, 0)
            pid_found = True
        except OSError:
            pid_found = False
        if pid_found:
            sys.stderr.write("The server is already running.\n")
            sys.exit(1)
        else:
            os.unlink(pid_path)

    if settings.USERDIR_ROOT:
        setup_userdir()

    childpid = os.fork()
    if childpid == 0:
        os.setsid()

        log_fn = os.path.join(settings.STATE_ROOT, "server.log")
        try:
            log_fd = os.open(log_fn, os.O_WRONLY | os.O_APPEND | os.O_CREAT)
        except OSError:
            log_fd = -1
        if log_fd < 0:
            sys.stderr.write("Could not open log file; logging to stdout.\n")
        else:
            os.dup2(log_fd, 1)
            os.dup2(log_fd, 2)

        os.close(0)

        manager_args = ["janitor", "runserver", "--noreload"]
        if interface:
            manager_args.append(interface)

        execute_manager(settings, manager_args)
    else:
        time.sleep(1)

        pid_file = open(pid_path, "w")
        pid_file.write(str(childpid))
        pid_file.close()

        if run_browser:
            if interface:
                if interface.find(":") != -1:
                    (ipaddr, port) = interface.split(":")
                    if ipaddr == "0.0.0.0":
                        interface = "127.0.0.1:" + port
                app_url = "http://%s/" % interface
            else:
                app_url = "http://127.0.0.1:8000/"
            sys.stdout.write("Waiting for the server to start...\n")
            time.sleep(10)
            sys.stdout.write("Starting a web browser.\n")
            os.execlp("xdg-open", "xdg-open", app_url)
        else:
            sys.exit(0)
Exemplo n.º 48
0
#!/usr/bin/env python
import sys
import os.path as op

def apath(x):
    import os
    return os.path.abspath(os.path.join(os.path.dirname(__file__),x))

sys.path.insert(0,apath('..'))
sys.path.insert(0,apath('../../'))

from django.core.management import execute_manager
import imp
try:
    imp.find_module('settings') # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
    sys.exit(1)

import webscanner.settings


if __name__ == "__main__":
    execute_manager(webscanner.settings)
Exemplo n.º 49
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import common.startup
from django.core.management import execute_manager
from web import settings
from common.terminal import welcomes

# Imports Django settings, displays a welcome message, and launches the development server.
if __name__ == '__main__':
    welcomes.web()
    execute_manager(settings)
Exemplo n.º 50
0
#!/usr/bin/python2
import sys
from tupa.dia2django import luoMallienRungot
from django.core.management import execute_manager
#try:
import settings  #
import legacySettings  # Legacy settings for exporting an legacy db
#except ImportError:
#import sys
#    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
#    sys.exit(1)

if __name__ == "__main__":
    set = settings
    if len(sys.argv):
        if sys.argv[1] == 'dumpdata':
            set = legacySettings
    execute_manager(set)
Exemplo n.º 51
0
def main():
    """Main entry point"""
    (options, args) = parseOptions()

    # What do we want to do ?
    if options.shell:
        Shell().loop()

    if options.web:
        execute_manager(settings, argv=[__file__, "runserver"])
        exit(0)

    if options.doc and options.gui:
        print "You must choose doc *or* gui, but not both ! (see --help)"
        exit(1)

    if options.doc:
        type = "doc"
    elif options.gui:
        type = "gui"
    else:
        print "You must choose either doc (-d) or gui (-g)"
        exit(1)

    if options.filename and not options.type:
        print "Type must be defined for page generation (see --help)"
        exit(1)
    elif not options.filename and options.type:
        print "Filename must be defined for page generation (see --help)"
        exit(1)
    elif options.filename and options.type:
        # Check file
        if not checkFile(options.filename):
            exit(1)
        # Choose correct type
        if options.type == "po":
            print "Creating PO page"
            file(options.filename,
                 "w").write(bookingPage(type).encode("UTF-8"))
        elif options.type == "translator":
            print "Creating Translator page"
            file(options.filename,
                 "w").write(translatorsPage(type).encode("UTF-8"))
            file(options.filename[:-3] + "csv", "w").write(
                translatorsPage(type, format="csv").encode("UTF-8"))
        elif options.type == "stat":
            print "Creating statistics page"
            file(options.filename, "w").write(statsPage(type).encode("UTF-8"))
        else:
            print "Ouha. Something goes wrong, type should have be correctly defined here !!!"
            exit(1)
    elif options.update:
        print "Update from SVN is not yet implemented"
    elif options.sync:
        sync(type=type)
    elif options.poStat:
        if options.pologyXml:
            poStat(readPologyXmlStat(options.pologyXml), type=type)
        else:
            print "pology XML path must be defined for this action"
            exit(1)
    elif options.errorsStat:
        if options.pologyXml:
            for sieve in SIEVES.keys():
                createPologyXMLStat(options.pologyXml, sieve=sieve, type=type)
        else:
            print "pology XML path must be defined for this action"
            exit(1)
    elif options.move:
        path = abspath(options.move)
        if not isdir(path):
            print "%s is not a directory" % options.move
            exit(1)
        movePos(path, type=type)
    else:
        print "Use --help for help"
        exit(1)
Exemplo n.º 52
0
from django.core.management import execute_manager
import imp

try:
    imp.find_module('live_settings')
except ImportError:
    import sys
    sys.stderr.write(
        "Error: Can't find the file 'live_settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n"
        % __file__)
    sys.exit(1)

import live_settings
if __name__ == "__main__":
    execute_manager(live_settings)
Exemplo n.º 53
0
import os
import sys

SETTINGSMODULE = os.environ.get('DJANGO_SETTINGS_MODULE', None) or 'settings'

sys.path.append(
    os.path.abspath(
        os.path.join(os.path.realpath(os.path.dirname(__file__)),
                     os.path.pardir)))

mpaths = SETTINGSMODULE.rsplit('.', 1)
mpath = mpaths[0]
mfrom = [mpaths[1]] if len(mpaths) > 1 else []

modobj = None

try:
    modobj = __import__(SETTINGSMODULE, fromlist=mfrom)
except ImportError, e:
    import sys
    sys.stderr.write(str(e))
    sys.stderr.write("""
        Error: Can't find the file 'settings.py' in the directory containing %r
        It appears you've customized things.
        You'll have to run django-admin.py, passing it your settings module.
        """ % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(modobj)
Exemplo n.º 54
0
#!/usr/bin/env python
from django.core.management import execute_manager
import settings_devel

if __name__ == "__main__":
    execute_manager(settings_devel)
Exemplo n.º 55
0
environ[
    "DJANGO_SETTINGS_MODULE"] = "portal.plugins.gnmpagerduty.tests.django_test_settings"
environ[
    "CI"] = "True"  #simulate a CI environment even if we're not in one, this will stop trying to import portal-specific stuff
#which breaks the tests
from django.core.management import execute_manager
import django.test
import unittest
from mock import patch, MagicMock
import os.path

import portal.plugins.gnmpagerduty.tests.django_test_settings as django_test_settings

if os.path.exists(django_test_settings.DATABASES['default']['NAME']):
    unlink(django_test_settings.DATABASES['default']['NAME'])
execute_manager(django_test_settings, ['manage.py', 'syncdb', "--noinput"])
execute_manager(django_test_settings, ['manage.py', 'migrate', "--noinput"])


class TestViews(django.test.TestCase):
    class MockObject(object):
        """
        fakes a .__dict__() method on something that is already a dict
        """
        def __init__(self, obj):
            self.obj = obj

        @property
        def __dict__(self):
            return self.obj
Exemplo n.º 56
0
#------------------------------------------------------------------------------
# main

st = L2VisionSniffer.SnifferThread()
gt = L2VisionGrapher.GrapherThread()
try:
    if len(sys.argv) == 1:
        port = 8000
    elif len(sys.argv) == 2:
        port = int(sys.argv[1])
    else:
        print "Usage: python L2Vision.py [portnumber]"
        sys.exit(1)

    print "L2 Vision %s" % L2VisionModel._version

    print "Starting UDP sniffer"
    st.start()

    print "Starting grapher"
    gt.start()

    execute_manager(settings,
                    ["django", "runserver", "--noreload",
                     "0.0.0.0:%d" % port])
finally:
    print "Shutting down."
    st.running = False
    gt.running = False
Exemplo n.º 57
0
#!/usr/bin/python -u

import sys, os, getpass
os.environ['DJANGO_SETTINGS_MODULE'] = 'gmail.settings'
import gmail.settings as settings

if not os.path.isdir(settings.MAIL_STORE):
    print "NOTICE: creating directory for local storage at:"
    print "        '%s'" % settings.MAIL_STORE
    os.mkdir(settings.MAIL_STORE)
if not os.path.isfile(settings.DATABASE_NAME):
    print "NOTICE: creating local storage state database"
    print "        '%s'" % settings.DATABASE_NAME
    from django.core.management import execute_manager
    execute_manager(settings, [sys.argv[0], 'syncdb'])

from gmail.sync import lib

from optparse import OptionParser
usage = """
  %prog [options] [email]

If you don't provide an email address and only
one account exists, it will be used; otherwise
you will be prompted to choose among the existing
or create one. If you provide an email which has
no related account information, you will be
asked to create a new one.
"""
parser = OptionParser(usage=usage)
#parser.add_option("-f", "--file", dest="filename",
Exemplo n.º 58
0
#!/usr/bin/env python
from django.core.management import execute_manager
try:
    import localsettings  # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write(
        "Error: Can't find the file 'localsettings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n"
        % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(localsettings)
Exemplo n.º 59
0
import os

from djangoconfig import setup_environment

try:
    setup_environment(__file__)
except KeyboardInterrupt:
    print ""
    print "Exiting script."
    sys.exit(0)

import settings
from django.core import management

if __name__ == "__main__":
    management.execute_manager(settings)

########NEW FILE########
__FILENAME__ = models
from django.db import models


class FlyingCircus(models.Model):
    name = models.CharField(max_length=100)
    description = models.TextField()

    def __unicode__(self):
        return self.name


########NEW FILE########
Exemplo n.º 60
0
def main():
    """Command-line interface"""
    if len(sys.argv) == 2 and sys.argv[1] == 'runserver':
        sys.argv.append(settings.DEV_SERVER_ADDR)
    execute_manager(settings)