def connect_db(cfg): try: conn = MySQLdb.connect(host=cfg['DB_HOST'], port=cfg['DB_PORT'], user=cfg['DB_USER'], passwd=cfg['DB_PASS'], db=cfg['DB_NAME'], use_unicode=True, charset="utf8") return conn except Exception, e: logging.getLogger().critical('connect db: %s' % e) return None
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import json from dashboard import corelib from dashboard import config from dashboard.utils.logger import logging log = logging.getLogger(__file__) class UserToken(object): def __init__(self, name, sig): self.name = name self.sig = sig def __repr__(self): return "<UserToken name=%s, sig=%s>" % (self.name, self.sig) __str__ = __repr__ class User(object): def __init__(self, id, name, cnname, email, phone, im, qq, role):