Пример #1
0
def run(mainframe, x):
    from modules.EasyGuider import EasyCommander
    easy = EasyCommander.EasyCommander(parent=mainframe,
                                       easyfile='easyDjango.py',
                                       inline=True,
                                       cmdoption='',
                                       outputencoding=x.options.encoding)
    if easy.run():
        values = easy.GetValue()
        values['secret_key'] = get_secret_key()
        if values['db_port'] == 0:
            values['db_port'] = ''

        from modules.meteor import TemplateScript
        #        from StringIO import StringIO
        #        buf = StringIO()
        #        template = Template()
        #        template.load('plugin.script', 'text')
        #        buf.write(template.value('text', EasyUtils.str_object(values)))
        #        buf.seek(0)
        #        ts = TemplateScript()
        ts = TemplateScript()
        ts.run('django.script', vars=values, runtemplate=True)
        from modules.DjangoIni import DjangoIni
        import os
        ini = DjangoIni(
            os.path.join(values['proj_dir'], values['proj_name'],
                         'settings.py'))
        ini['ADMINS'].append((values['username'], values['email']))
        ini['DATABASE_ENGINE'] = values['database']
        ini['DATABASE_NAME'] = values['db_file']
        ini['DATABASE_PASSWORD'] = values['db_password']
        ini['DATABASE_HOST'] = values['db_host']
        ini['DATABASE_PORT'] = values['db_port']
        ini['TIME_ZONE'] = values['time_zone']
        ini['LANGUAGE_CODE'] = values['language']
        ini['MEDIA_ROOT'] = os.path.join(values['proj_dir'],
                                         values['proj_name'],
                                         'media').replace('\\', '/')
        ini['SECRET_KEY'] = values['secret_key']
        ini['ROOT_URLCONF'] = values['proj_name'] + '.urls'
        ini.save()

        return True
Пример #2
0
def run(mainframe, x):
    from modules.EasyGuider import EasyCommander

    easy = EasyCommander.EasyCommander(
        parent=mainframe, easyfile="easyDjango.py", inline=True, cmdoption="", outputencoding=x.options.encoding
    )
    if easy.run():
        values = easy.GetValue()
        values["secret_key"] = get_secret_key()
        if values["db_port"] == 0:
            values["db_port"] = ""

        from modules.meteor import TemplateScript

        #        from StringIO import StringIO
        #        buf = StringIO()
        #        template = Template()
        #        template.load('plugin.script', 'text')
        #        buf.write(template.value('text', EasyUtils.str_object(values)))
        #        buf.seek(0)
        #        ts = TemplateScript()
        ts = TemplateScript()
        ts.run("django.script", vars=values, runtemplate=True)
        from modules.DjangoIni import DjangoIni
        import os

        ini = DjangoIni(os.path.join(values["proj_dir"], values["proj_name"], "settings.py"))
        ini["ADMINS"].append((values["username"], values["email"]))
        ini["DATABASE_ENGINE"] = values["database"]
        ini["DATABASE_NAME"] = values["db_file"]
        ini["DATABASE_PASSWORD"] = values["db_password"]
        ini["DATABASE_HOST"] = values["db_host"]
        ini["DATABASE_PORT"] = values["db_port"]
        ini["TIME_ZONE"] = values["time_zone"]
        ini["LANGUAGE_CODE"] = values["language"]
        ini["MEDIA_ROOT"] = os.path.join(values["proj_dir"], values["proj_name"], "media").replace("\\", "/")
        ini["SECRET_KEY"] = values["secret_key"]
        ini["ROOT_URLCONF"] = values["proj_name"] + ".urls"
        ini.save()

        return True
Пример #3
0
def OnDjangoInstallConApp(win, appname):
    oldpath = os.getcwd()
    try:
        path = win.getCurrentProjectHome()
        os.chdir(path)
        module = ''
        if appname == 'admin':
            module = 'django.contrib.admin'
        settings_file = os.path.join(path, 'settings.py')
        from modules.DjangoIni import DjangoIni
        ini = DjangoIni(settings_file)
        if module not in ini['INSTALLED_APPS']:
            ini['INSTALLED_APPS'].append(module)
            ini.save()
        fin, fout = os.popen4('python manage.py install %s' % appname)
        text = fout.read()
        if not text.strip():
            wx.CallAfter(common.showmessage, win, tr('Completed!'))
        else:
            wx.CallAfter(common.show_in_message_window, text)
    finally:
        os.chdir(oldpath)
Пример #4
0
def OnDjangoInstallConApp(win, appname):
    oldpath = os.getcwd()
    try:
        path = win.getCurrentProjectHome()
        os.chdir(path)
        module = ''
        if appname == 'admin':
            module = 'django.contrib.admin'
        settings_file = os.path.join(path, 'settings.py')
        from modules.DjangoIni import DjangoIni
        ini = DjangoIni(settings_file)
        if module not in ini['INSTALLED_APPS']:
            ini['INSTALLED_APPS'].append(module)
            ini.save()
        fin, fout = os.popen4('python manage.py install %s' % appname)
        text = fout.read()
        if not text.strip():
            wx.CallAfter(common.showmessage, win, tr('Completed!'))
        else:
            wx.CallAfter(common.show_in_message_window, text)
    finally:
        os.chdir(oldpath)
Пример #5
0
def OnDjangoInstallApp(win):
    oldpath = os.getcwd()
    try:
        path = win.getCurrentProjectHome()
        os.chdir(path)
        module = os.path.basename(path)
        settings_file = os.path.join(path, 'settings.py')
        from modules.DjangoIni import DjangoIni
        ini = DjangoIni(settings_file)
        item = win.tree.GetSelection()
        appname = os.path.basename(win.get_node_filename(item))
        module = str('.'.join([module, appname]))
        if module not in ini['INSTALLED_APPS']:
            ini['INSTALLED_APPS'].append(module)
            ini.save()
        fin, fout = os.popen4('python manage.py install %s' % appname)
        text = fout.read()
        if not text.strip():
            wx.CallAfter(common.showmessage, win, tr('Completed!'))
        else:
            wx.CallAfter(common.show_in_message_window, text)
    finally:
        os.chdir(oldpath)
Пример #6
0
def OnDjangoInstallApp(win):
    oldpath = os.getcwd()
    try:
        path = win.getCurrentProjectHome()
        os.chdir(path)
        module = os.path.basename(path)
        settings_file = os.path.join(path, 'settings.py')
        from modules.DjangoIni import DjangoIni
        ini = DjangoIni(settings_file)
        item = win.tree.GetSelection()
        appname = os.path.basename(win.get_node_filename(item))
        module = str('.'.join([module, appname]))
        if module not in ini['INSTALLED_APPS']:
            ini['INSTALLED_APPS'].append(module)
            ini.save()
        fin, fout = os.popen4('python manage.py install %s' % appname)
        text = fout.read()
        if not text.strip():
            wx.CallAfter(common.showmessage, win, tr('Completed!'))
        else:
            wx.CallAfter(common.show_in_message_window, text)
    finally:
        os.chdir(oldpath)