modified settings.py set option

pull/6/head
guanghongwei 2014-12-22 18:34:08 +08:00
parent 6a2e6709b9
commit 99f95af74e
3 changed files with 54 additions and 9 deletions

View File

@ -10,7 +10,6 @@ import struct
import fcntl import fcntl
import signal import signal
try: try:
import termios import termios
import tty import tty
@ -32,10 +31,11 @@ def red_print(string):
def alert_print(string): def alert_print(string):
red_print(string) red_print('AlertError: %s' % string)
time.sleep(2) time.sleep(2)
sys.exit() sys.exit()
def get_win_size(): def get_win_size():
"""This function use to get the size of the windows!""" """This function use to get the size of the windows!"""
if 'TIOCGWINSZ' in dir(termios): if 'TIOCGWINSZ' in dir(termios):
@ -110,6 +110,7 @@ def posix_shell(chan, user, host):
finally: finally:
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_tty) termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_tty)
log.close()
def connect(username, password, host, port): def connect(username, password, host, port):
@ -140,7 +141,7 @@ def connect(username, password, host, port):
except: except:
pass pass
# set PS1 and msg it # Set PS1 and msg it
channel.send(ps1) channel.send(ps1)
channel.send(login_msg) channel.send(login_msg)
print channel.get_name() print channel.get_name()
@ -148,7 +149,7 @@ def connect(username, password, host, port):
# Make ssh interactive tunnel # Make ssh interactive tunnel
posix_shell(channel, username, host) posix_shell(channel, username, host)
# shutdown channel socket # Shutdown channel socket
channel.close() channel.close()
ssh.close() ssh.close()

View File

@ -1,3 +1,10 @@
#coding: utf8 #coding: utf8
[jumpserver] [db]
host = 127.0.0.1
port = 3306
user = jumpserver
password = mysql345
database = jumpserver

View File

@ -10,8 +10,18 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) import ConfigParser
config = ConfigParser.ConfigParser()
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
config.read(os.path.join(BASE_DIR, 'jumpserver.conf'))
DB_HOST = config.get('db', 'host')
DB_PORT = config.getint('db', 'port')
DB_USER = config.get('db', 'user')
DB_PASSWORD = config.get('db', 'password')
DB_DATABASE = config.get('db', 'database')
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
@ -36,12 +46,14 @@ INSTALLED_APPS = (
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'juser',
'jasset',
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', #'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
@ -58,11 +70,34 @@ WSGI_APPLICATION = 'jumpserver.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.mysql',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'NAME': DB_DATABASE,
'USER': DB_USER,
'PASSWORD': DB_PASSWORD,
'HOST': DB_HOST,
'PORT': DB_PORT,
} }
} }
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
)
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
#STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/ # https://docs.djangoproject.com/en/1.7/topics/i18n/
@ -81,3 +116,5 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.7/howto/static-files/ # https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'
SESSION_COOKIE_AGE = 3600