Ejemplo n.º 1
0
def do_restart(request):
    """
    * "test" for a django instance (this do a touch over settings.py for reload)
    * "apache"
    * "httpd"
    * "wsgi"
    * "restart_script <script_path_name>"
    """
    if request.user.is_staff:
        reload_method = get_auto_reload_method()
        reload_log = get_auto_reload_log()
        reload_time = get_auto_reload_time()
        command = "echo no script"
        if reload_method == "test":
            command = "touch settings.py"
        ## No RedHAT or similars
        elif reload_method == "apache2":
            command = "sudo apache2ctl restart"
        ## RedHAT, CentOS
        elif reload_method == "httpd":
            command = "sudo service httpd restart"

        elif reload_method.startswith("restart_script"):
            script = reload_method.split(" ")[1]
            command = "%s &" % script
        os.system("sleep 2 && %s &> %s & " % (command, reload_log))

        return render_to_response(
            "inlinetrans/response.html", {"message": reload_time}, context_instance=RequestContext(request)
        )
Ejemplo n.º 2
0
def do_restart(request):
    """
    * "test" for a django instance (this do a touch over settings.py for reload)
    * "apache"
    * "httpd"
    * "wsgi"
    * "restart_script <script_path_name>"
    """
    if get_user_can_translate(request.user):
        reload_method = get_auto_reload_method()
        reload_log = get_auto_reload_log()
        reload_time = get_auto_reload_time()
        command = "echo no script"
        if reload_method == 'test':
            command = 'touch %s' % os.path.join(settings.BASEDIR,
                                                'settings.py')
        ## No RedHAT or similars
        elif reload_method == 'apache2':
            command = 'sudo apache2ctl restart'
        ## RedHAT, CentOS
        elif reload_method == 'httpd':
            command = 'sudo service httpd restart'

        elif reload_method.startswith('restart_script'):
            command = ' '.join(reload_method.split(" ")[1:])
        if os.path.exists(os.path.dirname(reload_log)):
            os.system("sleep 2 && %s &> %s & " % (command, reload_log))
        else:
            print('The AUTO_RELOAD_LOG directory do not exist'
                  )  # Just in case our stdout is logged somewhere
            os.system("sleep 2 && %s & " % command)
        return render_to_response('inlinetrans/response.html',
                                  {'message': reload_time},
                                  context_instance=RequestContext(request))
Ejemplo n.º 3
0
def do_restart(request):
    """
    * "test" for a django instance (this do a touch over settings.py for reload)
    * "apache"
    * "httpd"
    * "wsgi"
    * "restart_script <script_path_name>"
    """
    if request.user.is_staff:
        reload_method = get_auto_reload_method()
        reload_log = get_auto_reload_log()
        reload_time = get_auto_reload_time()
        command = "echo no script"
        if reload_method == 'test':
            command = 'touch settings.py'
        ## No RedHAT or similars
        elif reload_method == 'apache2':
            command = 'sudo apache2ctl restart'
        ## RedHAT, CentOS
        elif reload_method == 'httpd':
            command = 'sudo service httpd restart'

        elif reload_method.startswith('restart_script'):
            command = ' '.join(reload_method.split(" ")[1:])
        if os.path.exists(os.path.dirname(reload_log)):
            os.system("sleep 2 && %s &> %s & " % (command, reload_log))
        else:
            print 'The AUTO_RELOAD_LOG directory do not exist'  # Just in case our stdout is logged somewhere
            os.system("sleep 2 && %s & " % command)

        return render_to_response('inlinetrans/response.html',
                                  {'message': reload_time},
                                  context_instance=RequestContext(request))
Ejemplo n.º 4
0
def do_restart(request):
    """
    * "test" for a django instance (this do a touch over settings.py for reload)
    * "apache"
    * "httpd"
    * "wsgi"
    * "restart_script <script_path_name>"
    """
    if request.user.is_staff:
        if int(request.environ.get('mod_wsgi.script_reloading', '0')) and \
                request.environ.has_key('mod_wsgi.process_group') and \
                request.environ.get('mod_wsgi.process_group',None) and \
                request.environ.has_key('SCRIPT_FILENAME'):
            try:
                os.utime(request.environ.get('SCRIPT_FILENAME'), None)
            except OSError:
                pass

        #reload_method = get_auto_reload_method()
        #reload_log = get_auto_reload_log()
        reload_time = get_auto_reload_time()
        #command = "echo no script"
        #if reload_method == 'test':
        #    command = 'touch settings.py'
        ### No RedHAT or similars
        #elif reload_method == 'apache2':
        #    command = 'sudo apache2ctl restart'
        ### RedHAT, CentOS
        #elif reload_method == 'httpd':
        #    command = 'sudo service httpd restart'

        #elif reload_method.startswith('restart_script'):
        #    command = ' '.join(reload_method.split(" ")[1:])
        #if os.path.exists(os.path.dirname(reload_log)):
        #    os.system("sleep 2 && %s &> %s & " % (command, reload_log))
        #else:
        #    print 'The AUTO_RELOAD_LOG directory do not exist'  # Just in case our stdout is logged somewhere
        #    os.system("sleep 2 && %s & " % command)

        return render_to_response('inlinetrans/response.html',
                                  {'message': reload_time},
                                  context_instance=RequestContext(request))