def startup(): bpa_path = os.path.dirname(os.path.abspath(BiblioPixelAnimations.__file__)).replace("\\", "/") bpa_matrix = bpa_path + "/matrix/" bpa_strip = bpa_path + "/strip/" bpa_recv = bpa_path + "/receivers/" bpa_circle = bpa_path + "/circle/" status.pushStatus("Starting PixelWeb Server") config.initConfig() status.pushStatus("Reading server config") config.upgradeServerConfig() cfg = globals._server_config = config.readServerConfig() # if(bpa_matrix not in cfg.mod_dirs): cfg.mod_dirs.append(bpa_matrix) # if(bpa_strip not in cfg.mod_dirs): cfg.mod_dirs.append(bpa_strip) globals._bpa_dirs = [bpa_matrix, bpa_strip, bpa_recv, bpa_circle] level = log.INFO if cfg.show_debug: level = log.DEBUG log.setLogLevel(level) mod_dir = os.path.join(config.__home, "mods") if os.path.isdir(mod_dir): globals._bpa_dirs.append(mod_dir) initBPM()
def startup(): bpa_path = os.path.dirname(os.path.abspath( BiblioPixelAnimations.__file__)).replace("\\", "/") bpa_matrix = bpa_path + "/matrix/" bpa_strip = bpa_path + "/strip/" bpa_recv = bpa_path + "/receivers/" bpa_circle = bpa_path + "/circle/" status.pushStatus("Starting PixelWeb Server") config.initConfig() status.pushStatus("Reading server config") config.upgradeServerConfig() cfg = globals._server_config = config.readServerConfig() # if(bpa_matrix not in cfg.mod_dirs): cfg.mod_dirs.append(bpa_matrix) # if(bpa_strip not in cfg.mod_dirs): cfg.mod_dirs.append(bpa_strip) globals._bpa_dirs = [bpa_matrix, bpa_strip, bpa_recv, bpa_circle] level = log.INFO if cfg.show_debug: level = log.DEBUG log.setLogLevel(level) mod_dir = os.path.join(config.__home, 'mods') if os.path.isdir(mod_dir): globals._bpa_dirs.append(mod_dir) initBPM()
def main(): args = initParser() config = initConfig(args.settings_file) db = initDatabase(config) initLogging(config) if exists(args.filename): log_entry = LogEntry(args.filename) db.insert_entry(log_entry) return 0 else: logging.error("%s does not exist. Exiting..." % args.filename) return 1
from urllib import urlencode from config import initConfig class NullHandler(logging.Handler): def emit(self, record): pass h = NullHandler() logging.getLogger("rhsm").addHandler(h) log = logging.getLogger(__name__) config = initConfig() class ConnectionException(Exception): pass class ConnectionSetupException(ConnectionException): pass class BadCertificateException(ConnectionException): """ Thrown when an error parsing a certificate is encountered. """ def __init__(self, cert_path): """ Pass the full path to the bad certificate. """ self.cert_path = cert_path
#!/usr/bin/env python3.4 import os import sys import config import db import datetime import vk_api import telebot import threading import urllib.request as ur from PIL import Image # Для преобразования изображений из webp в PNG config.initConfig() module = sys.modules[__name__] # Код настоятельно рекомендуется читать снизу вверх! # _______ _ # |__ __| | | # | | ___ ___| |__ # | |/ _ \/ __| '_ \ # | | __/ (__| | | | # |_|\___|\___|_| |_| # # Технические функции # Получаем текущее время def current_time(): delta = datetime.timedelta( hours=3 ) utc = datetime.timezone.utc
pass def safe_int(value, safe_value=None): try: return int(value) except: return safe_value h = NullHandler() logging.getLogger("rhsm").addHandler(h) log = logging.getLogger(__name__) config = initConfig() class ConnectionException(Exception): pass class ConnectionSetupException(ConnectionException): pass class BadCertificateException(ConnectionException): """ Thrown when an error parsing a certificate is encountered. """ def __init__(self, cert_path): """ Pass the full path to the bad certificate. """
#!/usr/bin/env python3.4 import os import sys import config import db import datetime import vk_api import telebot import threading import httplib2 # Не работает на бесплатном аккаунте pythonanywhere from PIL import Image # Для преобразования изображений из webp в PNG config.initConfig() module = sys.modules[__name__] # Код настоятельно рекомендуется читать снизу вверх! # _____ _ _ _ # / ____| | | (_) | # | (___ ___ _ __ ___ ___ ___| |__ _| |_ # \___ \ / _ \| '_ ` _ \ / _ \ / __| '_ \| | __| # ____) | (_) | | | | | | __/ \__ \ | | | | |_ # |_____/ \___/|_| |_| |_|\___| |___/_| |_|_|\__| # # Технические функции # Получаем текущее время def current_time(): delta = datetime.timedelta(hours=3)
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import sys import os import config from ga4gh import create_app from ga4gh import views ga4ghPath = None for path in sys.path: if path.endswith('web'): ga4ghPath = path break if ga4ghPath is None: raise Exception("GA4GHAPI path is not set. Run GenomicsSampleAPIs/web/install.py, \ and use --system-site-packages when creating a virtualenv") config.initConfig(os.path.join(ga4ghPath, "ga4gh_test.conf")) if os.getenv('VIRUTAL_ENV') is None: activate_this = config.LoadedConfig.VIRTUALENV + '/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) application = create_app('config.LoadedConfig') application.register_blueprint(views.ga4gh)
from ga4gh import create_app from flask.ext.cors import CORS from flask.ext.cors import cross_origin from ga4gh import views from ga4gh.views import ga4gh # works with new virutalenv changes basePath = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))) configFile = os.path.join(basePath, "web/ga4gh_test.conf") parser = config.ConfigParser.RawConfigParser() parser.read(configFile) if parser.has_section('virtualenv'): venv = parser.get('virtualenv', 'virtualenv') if os.getenv('VIRUTAL_ENV') is None: activate_this = venv + '/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) config.initConfig("ga4gh_test.conf") app = create_app(config.LoadedConfig) cors = CORS(app) app.config['CORS_HEADERS'] = 'Content-Type' host = app.config.get('HOST', 'localhost') app.register_blueprint(views.ga4gh) if __name__ == '__main__': app.run(host=host, debug=True)
import simplejson as json from rq import Queue from config import initConfig from rq_scheduler import Scheduler from config import config from datetime import timedelta import http import util import gevent import redis import aliyun import sys reload(sys) sys.setdefaultencoding('utf8') api_list_config = initConfig() r = redis.StrictRedis(config.get("redis", "store_host"), db=config.get("redis", "store_db")) scheduler = Scheduler(connection=Redis(config.get("redis", "host")), queue_name=config.get("redis", "Queue")) q = Queue(connection=Redis(config.get("redis", "host")), name=config.get("redis", "Log")) logger = logging.getLogger('worker') LOG_FILENAME = config.get("log", "LOG_PATH") + 'get_api.log' exec('logger.setLevel(%s)' % config.get('log', 'log_level')) format = "%(asctime)s %(filename)s %(lineno)d %(levelname)s %(message)s" handler = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, "midnight", 1, 30) handler.setFormatter(logging.Formatter(format))
def main(): try: jsonCheck() initConfig() except KeyboardInterrupt: pass
#!/usr/bin/python import unittest import config config.initConfig('config/test_conf.conf') # must be called before importing models to ensure memory based db from models.model import Player, Match, Team, initSchema, dropSchema, sessionmaker, engine Session = sessionmaker(bind=engine) class ModelsTest(unittest.TestCase): def setUp(self): initSchema() self.session = Session() def tearDown(self): self.session.close() dropSchema() def test_player_createOrLoad_same(self): playerA = Player.createOrLoad('1',self.session) self.session.commit() playerB = Player.createOrLoad('1',self.session) self.assertEqual(playerA,playerB) def test_player_createOrLoad_different(self): playerA = Player.createOrLoad('1',self.session) self.session.commit() playerB = Player.createOrLoad('2',self.session) self.assertNotEqual(playerA,playerB)