コード例 #1
0
ファイル: main.py プロジェクト: rpedroso/gweb2py
    def start(self, passwd, port):
        self.process = wx.Process(self.parent)
        self.process.Redirect()
        p = self.app_path
        sys.path.insert(0, self.w2p_path)

        os.chdir(self.w2p_path)

        if not os.path.isfile('web2py.py'):
            self.process = None
            raise Exception('%s: Execution failed' % 'web2py.py')

        if passwd:
            passwd = passwd.strip()
            from gluon.main import save_password
            save_password(passwd, port)

        cmd = '"%s" -u "%s" %s "%s"' % (sys.executable,
                opj(p, 'gw2pserver.py'), port, self.w2p_path)

        self.pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process)

        if self.pid == 0:
            self.process = None
            raise Exception('%s: Execution failed' % 'web2py.py')
        self.is_running = True
コード例 #2
0
ファイル: web2py.py プロジェクト: tazjel/rad2py
                def server(host, port, password):
                    save_password(password, port)
                    qdb.init(redirect=False)
                    qdb.qdb.do_debug()

                    def wrapped_app(environ, start_response):
                        "WSGI wrapper to allow debugging"
                        # hanshake with front-end on each request (update ui)
                        # not realy needed (request processing is sequential)
                        ##qdb.qdb.startup()
                        # process the request as usual
                        return wsgibase(environ, start_response)

                    httpd2 = make_server(host, port, wrapped_app)
                    print "THREAD - Serving HTTP on port2 %s..." % port
                    httpd2.serve_forever(poll_interval=0.01)
コード例 #3
0
ファイル: web2py.py プロジェクト: agevole/rad2py
                def server(host, port, password):
                    save_password(password, port)
                    qdb.init(redirect=False)
                    qdb.qdb.do_debug()

                    def wrapped_app(environ, start_response):
                        "WSGI wrapper to allow debugging"
                        # hanshake with front-end on each request (update ui)
                        # not realy needed (request processing is sequential)
                        ##qdb.qdb.startup()
                        # process the request as usual
                        return wsgibase(environ, start_response)

                    httpd2 = make_server(host, port, wrapped_app)
                    print "THREAD - Serving HTTP on port2 %s..." % port
                    httpd2.serve_forever(poll_interval=0.01)
コード例 #4
0
ファイル: web2py.py プロジェクト: agevole/rad2py
    def OnAttachWebserver(self, event):
        "start-up a web2py server instance"

        # read configuration with safe defaults
        cfg = wx.GetApp().get_config("WEB2PY")
        path = cfg.get("path", "../web2py")
        password = cfg.get("password", "a")
        port = cfg.get("port", 8006)
        host = "127.0.0.1"

        if path:
            # store current directory
            prevdir = os.path.abspath(os.curdir)

            try:
                # update current directory and python path to find web2py:
                os.chdir(path)
                sys.path.insert(0, os.path.abspath(os.curdir))
                from gluon.main import wsgibase, save_password
                from gluon.contrib import qdb

                # store admin password
                save_password(password, port)

                web2py_env = {}  ##self.build_web2py_environment()

                # Start a alternate web2py in a separate thread (for blocking requests)
                from threading import Thread

                def server(host, port, password):
                    save_password(password, port)
                    qdb.init(redirect=False)
                    qdb.qdb.do_debug()

                    def wrapped_app(environ, start_response):
                        "WSGI wrapper to allow debugging"
                        # hanshake with front-end on each request (update ui)
                        # not realy needed (request processing is sequential)
                        ##qdb.qdb.startup()
                        # process the request as usual
                        return wsgibase(environ, start_response)

                    httpd2 = make_server(host, port, wrapped_app)
                    print "THREAD - Serving HTTP on port2 %s..." % port
                    httpd2.serve_forever(poll_interval=0.01)

                thread = Thread(target=server, args=(host, port, password))
                thread.daemon = True  # close on exit
                thread.start()

                # open internal browser at default page:
                url = "http://%s:%s/" % (host, port)
                if self.browser:
                    self.browser.LoadURL(url)
                    pass
                else:
                    # no internal browser, open external one
                    try:
                        import webbrowser

                        webbrowser.open(url)
                    except:
                        print "warning: unable to detect your browser"

            except Exception, e:
                self.ShowInfoBar(u"cannot start web2py!: %s" % unicode(e), flags=wx.ICON_ERROR, key="web2py")
                web2py_env = {}
            finally:
コード例 #5
0
ファイル: vidjil_utils.py プロジェクト: zhangjl-work/vidjil
def init_db_helper(db, auth, force=False, admin_email="*****@*****.**", admin_password="******"):
    from gluon.main import save_password
    from permission_enum import PermissionEnum
    if (force) or (db(db.auth_user.id > 0).count() == 0) : 
        if force:
            reset_db(db)

        id_first_user=""

        ## création du premier user
        id_first_user=db.auth_user.insert(
            password = db.auth_user.password.validate(admin_password)[0],
            email = admin_email,
            first_name = 'System',
            last_name = 'Administrator'
        )

        # set web2py administration interface password to the same as vidjil admin password
        save_password(admin_password, 443)

        ## création des groupes de base
        id_admin_group=db.auth_group.insert(role='admin')
        id_sa_group=db.auth_group.insert(role='user_1')
        id_public_group=db.auth_group.insert(role="public")

        db.auth_membership.insert(user_id=id_first_user, group_id=id_admin_group)
        db.auth_membership.insert(user_id=id_first_user, group_id=id_sa_group)
        db.auth_membership.insert(user_id=id_first_user, group_id=id_public_group)


        ### Base config classification
        db.classification.insert(
            name = 'Vidjil-algo',
            info = 'Vidjil-algo'
        )
        db.classification.insert(
            name = 'Sub groups',
            info = 'Sub groups'
        )
        db.classification.insert(
            name = 'Other germlines',
            info = 'Other germlines'
        )
        db.classification.insert(
            name = 'Other species',
            info = 'Other species'
        )
        db.classification.insert(
            name = 'Experimentals',
            info = 'Experimentals'
        )


        ## base Vidjil configs

        db.config.insert(
            name = 'default + extract reads',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g -e 1 -2 -d -w 50 -U ',
            fuse_command = '-t 100',
            info = 'Same as the default "multi+inc+xxx" (multi-locus, with some incomplete/unusual/unexpected recombinations), and extract analyzed reads in the "out" temporary directory.',
            classification = 1
        )
        db.config.insert(
            name = 'multi+inc+xxx',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g -e 1 -2 -d -w 50 ',
            fuse_command = '-t 100',
            info = 'multi-locus, with some incomplete/unusual/unexpected recombinations',
            classification = 1
        )
        db.config.insert(
            name = 'multi+inc',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g -e 1 -w 50 ',
            fuse_command = '-t 100',
            info = 'multi-locus, with some incomplete/unusual recombinations',
            classification = 1
        )
        db.config.insert(
            name = 'multi',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g:IGH,IGK,IGL,TRA,TRB,TRG,TRD -e 1 -d -w 50 ',
            fuse_command = '-t 100',
            info = 'multi-locus, only complete recombinations',
            classification = 2
        )
        db.config.insert(
            name = 'TRG',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g:TRG ',
            fuse_command = '-t 100',
            info = 'TRG, VgJg',
            classification = 2
        )
        db.config.insert(
            name = 'IGH',
            program = 'vidjil',
            command = '-c clones -w 60 -d -3 -z 100 -r 1 -g germline/h**o-sapiens.g:IGH ',
            fuse_command = '-t 100',
            info = 'IGH, Vh(Dh)Jh',
            classification = 2
        )

        ## permission
        ## system admin have admin/read/create rights on all patients, groups and configs
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.run, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.pre_process, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.run, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin_group.value, db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin_config.value, db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin_pre_process.value, db.pre_process, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.run, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read_group.value, db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read_config.value, db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read_pre_process.value, db.pre_process, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create.value, db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create_group.value, db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create_config.value, db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create_pre_process.value, db.pre_process, 0)
        auth.add_permission(id_admin_group, 'impersonate', db.auth_user, 0)

        auth.add_permission(id_public_group, PermissionEnum.read_config.value, db.config, 0)
        for config in db(db.config.id > 0).select():
            auth.add_permission(id_public_group, PermissionEnum.access.value, db.config, config.id)

        auth.add_permission(id_public_group, PermissionEnum.read_pre_process.value, db.pre_process, 0)
        for pre_process in db(db.pre_process.id > 0).select():
            auth.add_permission(id_public_group, PermissionEnum.access.value, db.pre_process, pre_process.id)

        tags = ['ALL', 'T-ALL',  'B-ALL',
                'pre-B-ALL','pro-B-ALL', 'mature-B-ALL',
                'CML', 'HCL', 'MZL', 'T-PLL',
                'CLL', 'LGL',
                'lymphoma',
                'MCL', 'NHL', 'HL', 'FL', 'DLBCL',
                'WM', 'MAG',
                'MM',
                'diagnosis', 'MRD', 'relapse', 'CR', 'deceased',
                'pre-BMT', 'post-BMT', 'pre-SCT', 'post-SCT',
                'dilution', 'standard',
                'QC', 'EuroMRD',
                'marrow', 'blood',
                'repertoire',
                'TIL', 'CAR-T', 'scFv',
                'FR1', 'FR2', 'FR3',
                'TRA', 'TRB', 'TRG', 'TRD',
                'IGH', 'IGK', 'KDE', 'IGL',
                'IKAROS',
                'BCR-ABL', 'TEL-AML1', 'E2A-PBX',
                'BCL2',
                'PAX5']
        for tag in tags:
            tid  = db.tag.insert(name=tag)
            db.group_tag.insert(group_id=id_public_group, tag_id=tid)
コード例 #6
0
 def f(host, port, password):
     save_password(password, port)
     httpd2 = make_server(host, port, wsgibase)
     print "THREAD - Serving HTTP on port2 %s..." % port
     httpd2.serve_forever()
コード例 #7
0
    def __init__(self, path="../web2py", port=8006, password="******"):
        "start-up a web2py server instance"

        self.menu['run'].Append(ID_ATTACH, "Attach &webserver\tCtrl-W",
                                "Connect to remote web2py debugger")
        self.Bind(wx.EVT_MENU, self.OnAttachWebserver, id=ID_ATTACH)

        # read configuration with safe defaults
        cfg = wx.GetApp().get_config("WEB2PY")
        path = cfg.get("path", path)
        password = cfg.get("password", password)
        port = cfg.get("port", port)
        host = "127.0.0.1"

        if path:
            # store current directory
            prevdir = os.path.abspath(os.curdir)

            try:
                os.chdir(path)
                sys.path.insert(0, path)
                from gluon.main import wsgibase, save_password

                # store admin password
                save_password(password, port)

                # create a wsgi server
                self.web2py_httpd = make_server(host, port, wsgibase)
                print "Serving HTTP on port %s..." % port

                # connect to idle event to poll and serve requests
                ##self.Bind(wx.EVT_IDLE, self.OnIdleServeWeb2py)

                # open internal browser at default page:
                url = "http://%s:%s/" % (host, port)
                if self.browser:
                    #self.browser.LoadURL(url)
                    pass
                else:
                    # no interna browser, open external one
                    try:
                        import webbrowser
                        webbrowser.open(url)
                    except:
                        print 'warning: unable to detect your browser'

                web2py_env = self.build_web2py_environment()

                if False:
                    # Start a alternate web2py in a separate thread (for blocking requests)
                    from threading import Thread

                    def f(host, port, password):
                        save_password(password, port)
                        httpd2 = make_server(host, port, wsgibase)
                        print "THREAD - Serving HTTP on port2 %s..." % port
                        httpd2.serve_forever()

                    p = Thread(target=f, args=("127.0.0.1", 8000, password))
                    p.start()

            except Exception, e:
                self.ShowInfoBar(u"cannot start web2py!: %s" % unicode(e),
                                 flags=wx.ICON_ERROR,
                                 key="web2py")
                web2py_env = {}
            finally:
コード例 #8
0
ファイル: vidjil_utils.py プロジェクト: vidjil/vidjil
def init_db_helper(db, auth, force=False, admin_email="*****@*****.**", admin_password="******"):
    from gluon.main import save_password
    from permission_enum import PermissionEnum
    if (force) or (db(db.auth_user.id > 0).count() == 0) : 
        if force:
            reset_db(db)

        id_first_user=""

        ## création du premier user
        id_first_user=db.auth_user.insert(
            password = db.auth_user.password.validate(admin_password)[0],
            email = admin_email,
            first_name = 'System',
            last_name = 'Administrator'
        )

        # set web2py administration interface password to the same as vidjil admin password
        save_password(admin_password, 443)

        ## création des groupes de base
        id_admin_group=db.auth_group.insert(role='admin')
        id_sa_group=db.auth_group.insert(role='user_1')
        id_public_group=db.auth_group.insert(role="public")

        db.auth_membership.insert(user_id=id_first_user, group_id=id_admin_group)
        db.auth_membership.insert(user_id=id_first_user, group_id=id_sa_group)
        db.auth_membership.insert(user_id=id_first_user, group_id=id_public_group)

        ## base Vidjil configs

        db.config.insert(
            name = 'default + extract reads',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g -e 1 -2 -d -w 50 -U ',
            fuse_command = '-t 100',
            info = 'Same as the default "multi+inc+xxx" (multi-locus, with some incomplete/unusual/unexpected recombinations), and extract analyzed reads in the "out" temporary directory.'
        )
        db.config.insert(
            name = 'multi+inc+xxx',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g -e 1 -2 -d -w 50 ',
            fuse_command = '-t 100',
            info = 'multi-locus, with some incomplete/unusual/unexpected recombinations'
        )
        db.config.insert(
            name = 'multi+inc',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g -e 1 -w 50 ',
            fuse_command = '-t 100',
            info = 'multi-locus, with some incomplete/unusual recombinations'
        )
        db.config.insert(
            name = 'multi',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g:IGH,IGK,IGL,TRA,TRB,TRG,TRD -e 1 -d -w 50 ',
            fuse_command = '-t 100',
            info = 'multi-locus, only complete recombinations'
        )
        db.config.insert(
            name = 'TRG',
            program = 'vidjil',
            command = '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g:TRG ',
            fuse_command = '-t 100',
            info = 'TRG, VgJg'
        )
        db.config.insert(
            name = 'IGH',
            program = 'vidjil',
            command = '-c clones -w 60 -d -3 -z 100 -r 1 -g germline/h**o-sapiens.g:IGH ',
            fuse_command = '-t 100',
            info = 'IGH, Vh(Dh)Jh'
        )

        ## permission
        ## system admin have admin/read/create rights on all patients, groups and configs
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.run, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.pre_process, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value, db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.run, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin_group.value, db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin_config.value, db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin_pre_process.value, db.pre_process, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.run, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read_group.value, db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read_config.value, db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read_pre_process.value, db.pre_process, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create.value, db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create_group.value, db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create_config.value, db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create_pre_process.value, db.pre_process, 0)
        auth.add_permission(id_admin_group, 'impersonate', db.auth_user, 0)

        auth.add_permission(id_public_group, PermissionEnum.read_config.value, db.config, 0)
        for config in db(db.config.id > 0).select():
            auth.add_permission(id_public_group, PermissionEnum.access.value, db.config, config.id)

        auth.add_permission(id_public_group, PermissionEnum.read_pre_process.value, db.pre_process, 0)
        for pre_process in db(db.pre_process.id > 0).select():
            auth.add_permission(id_public_group, PermissionEnum.access.value, db.pre_process, pre_process.id)

        tags = ['ALL', 'T-ALL',  'B-ALL',
                'pre-B-ALL','pro-B-ALL', 'mature-B-ALL',
                'CML', 'HCL', 'MZL', 'T-PLL',
                'CLL', 'LGL',
                'lymphoma',
                'MCL', 'NHL', 'HL', 'FL', 'DLBCL',
                'WM', 'MAG',
                'MM',
                'diagnosis', 'MRD', 'relapse', 'CR', 'deceased',
                'pre-BMT', 'post-BMT', 'pre-SCT', 'post-SCT',
                'dilution', 'standard',
                'QC', 'EuroMRD',
                'marrow', 'blood',
                'repertoire',
                'TIL', 'CAR-T', 'scFv',
                'FR1', 'FR2', 'FR3',
                'TRA', 'TRB', 'TRG', 'TRD',
                'IGH', 'IGK', 'KDE', 'IGL',
                'IKAROS',
                'BCR-ABL', 'TEL-AML1', 'E2A-PBX',
                'BCL2',
                'PAX5']
        for tag in tags:
            tid  = db.tag.insert(name=tag)
            db.group_tag.insert(group_id=id_public_group, tag_id=tid)
コード例 #9
0
os.chdir("/home/www-data/smc/web2py/")
#print os.getcwd()

from gluon.main import save_password

# RUN THIS FROM DOCKER CONTAINER
# TODO - make this pull from preset repository on boot?
# : docker exec -it ope_ope-smc_1 python /home/www-data/web2py/applications/smc/set_admin_password.py
# or: docker exec -it ope_ope-smc_1 /set_admin_password

password = ""
match = False

#if (len(sys.argv) >=2):
#    password = sys.argv[1]

while (match != True):
    pw = getpass("Please enter new admin password for SMC: ")
    pw2 = getpass("Enter password again to confirm: ")

    if (pw != pw2):
        print "\t\tPasswords don't match, try again!!!!"
    else:
        match = True
        password = pw

password = password.strip()
if (password != ""):
    save_password(password, 80)
    save_password(password, 443)
コード例 #10
0
ファイル: default.py プロジェクト: suntaosimon/vidjil
def init_db_helper(force=False,
                   admin_email="*****@*****.**",
                   admin_password="******"):
    if (force) or (db(db.auth_user.id > 0).count() == 0):
        #for table in db :
        #table.truncate()

        id_first_user = ""

        ## création du premier user
        id_first_user = db.auth_user.insert(
            password=db.auth_user.password.validate(admin_password)[0],
            email=admin_email,
            first_name='System',
            last_name='Administrator')

        # set web2py administration interface password to the same as vidjil admin password
        save_password(admin_password, 443)

        ## création des groupes de base
        id_admin_group = db.auth_group.insert(role='admin')
        id_sa_group = db.auth_group.insert(role='user_1')
        id_public_group = db.auth_group.insert(role="public")

        db.auth_membership.insert(user_id=id_first_user,
                                  group_id=id_admin_group)
        db.auth_membership.insert(user_id=id_first_user, group_id=id_sa_group)
        db.auth_membership.insert(user_id=id_first_user,
                                  group_id=id_public_group)

        ## base Vidjil configs

        db.config.insert(
            name='multi+inc+xxx',
            program='vidjil',
            command=
            '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g -e 1 -2 -d -w 50 ',
            fuse_command='-t 100',
            info=
            'multi-locus, with some incomplete/unusual/unexpected recombinations'
        )
        db.config.insert(
            name='multi+inc',
            program='vidjil',
            command=
            '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g -e 1 -w 50 ',
            fuse_command='-t 100',
            info='multi-locus, with some incomplete/unusual recombinations')
        db.config.insert(
            name='multi',
            program='vidjil',
            command=
            '-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g:IGH,IGK,IGL,TRA,TRB,TRG,TRD -i -e 1 -d -w 50 ',
            fuse_command='-t 100',
            info='multi-locus, only complete recombinations')
        db.config.insert(
            name='TRG',
            program='vidjil',
            command='-c clones -3 -z 100 -r 1 -g germline/h**o-sapiens.g:TRG ',
            fuse_command='-t 100',
            info='TRG, VgJg')
        db.config.insert(
            name='IGH',
            program='vidjil',
            command=
            '-c clones -w 60 -d -3 -z 100 -r 1 -g germline/h**o-sapiens.g:IGH ',
            fuse_command='-t 100',
            info='IGH, Vh(Dh)Jh')

        ## permission
        ## system admin have admin/read/create rights on all patients, groups and configs
        auth.add_permission(id_admin_group, PermissionEnum.access.value,
                            db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value,
                            db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value,
                            db.run, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value,
                            db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value,
                            db.config, 0)
        auth.add_permission(id_admin_group, PermissionEnum.access.value,
                            db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value,
                            db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value,
                            db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value,
                            db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin.value, db.run,
                            0)
        auth.add_permission(id_admin_group, PermissionEnum.admin_group.value,
                            db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.admin_config.value,
                            db.config, 0)
        auth.add_permission(id_admin_group,
                            PermissionEnum.admin_pre_process.value,
                            db.pre_process, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value,
                            db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value,
                            db.patient, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value, db.run,
                            0)
        auth.add_permission(id_admin_group, PermissionEnum.read.value,
                            db.generic, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read_group.value,
                            db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.read_config.value,
                            db.config, 0)
        auth.add_permission(id_admin_group,
                            PermissionEnum.read_pre_process.value,
                            db.pre_process, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create.value,
                            db.sample_set, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create_group.value,
                            db.auth_group, 0)
        auth.add_permission(id_admin_group, PermissionEnum.create_config.value,
                            db.config, 0)
        auth.add_permission(id_admin_group,
                            PermissionEnum.create_pre_process.value,
                            db.pre_process, 0)
        auth.add_permission(id_admin_group, 'impersonate', db.auth_user, 0)
コード例 #11
0
ファイル: web2py.py プロジェクト: tazjel/rad2py
    def OnAttachWebserver(self, event):
        "start-up a web2py server instance"

        # read configuration with safe defaults
        cfg = wx.GetApp().get_config("WEB2PY")
        path = cfg.get("path", "../web2py")
        password = cfg.get("password", "a")
        port = cfg.get("port", 8006)
        host = "127.0.0.1"

        if path:
            # store current directory
            prevdir = os.path.abspath(os.curdir)

            try:
                # update current directory and python path to find web2py:
                os.chdir(path)
                sys.path.insert(0, os.path.abspath(os.curdir))
                from gluon.main import wsgibase, save_password
                from gluon.contrib import qdb

                # store admin password
                save_password(password, port)

                web2py_env = {}  ##self.build_web2py_environment()

                # Start a alternate web2py in a separate thread (for blocking requests)
                from threading import Thread

                def server(host, port, password):
                    save_password(password, port)
                    qdb.init(redirect=False)
                    qdb.qdb.do_debug()

                    def wrapped_app(environ, start_response):
                        "WSGI wrapper to allow debugging"
                        # hanshake with front-end on each request (update ui)
                        # not realy needed (request processing is sequential)
                        ##qdb.qdb.startup()
                        # process the request as usual
                        return wsgibase(environ, start_response)

                    httpd2 = make_server(host, port, wrapped_app)
                    print "THREAD - Serving HTTP on port2 %s..." % port
                    httpd2.serve_forever(poll_interval=0.01)

                thread = Thread(target=server, args=(host, port, password))
                thread.daemon = True  # close on exit
                thread.start()

                # open internal browser at default page:
                url = "http://%s:%s/" % (host, port)
                if self.browser:
                    self.browser.LoadURL(url)
                    pass
                else:
                    # no internal browser, open external one
                    try:
                        import webbrowser
                        webbrowser.open(url)
                    except:
                        print 'warning: unable to detect your browser'

            except Exception, e:
                self.ShowInfoBar(u"cannot start web2py!: %s" % unicode(e),
                                 flags=wx.ICON_ERROR,
                                 key="web2py")
                web2py_env = {}
            finally:
コード例 #12
0
        os.chdir(application_path)
        check_output(['cp', 'handlers/wsgihandler.py', 'wsgihandler.py'])
        update_rights('wsgihandler.py', u_name='nginx', g_name=GROUP_NAME, octal_rights=755)
    except CalledProcessError as cpe:
        exit('An issue occurred, exiting !')
    print(SColors.OK_BLUE + 'ok' + SColors.END_C)

    # set admin password
    try:
        print(SColors.BOLD + '\nSet application Admin interface password..' + SColors.END_C, end=' ')
        os.chdir(application_path)
        sys.path.append(application_path)

        # noinspection PyUnresolvedReferences,PyUnresolvedReferences
        from gluon.main import save_password
        save_password(input(SColors.WARNING + '\n\n\tAdmin Password : '******'\n\nRestarting servers..' + SColors.END_C, end=' ')
    try:
コード例 #13
0
ファイル: web2py.py プロジェクト: Focus3D/rad2py
 def f(host, port, password):
     save_password(password, port)
     httpd2 = make_server(host, port, wsgibase)
     print "THREAD - Serving HTTP on port2 %s..." % port
     httpd2.serve_forever()
コード例 #14
0
ファイル: web2py.py プロジェクト: Focus3D/rad2py
    def __init__(self, path="../web2py", port=8006, password="******"):
        "start-up a web2py server instance"

        self.menu['run'].Append(ID_ATTACH, 
                                "Attach &webserver\tCtrl-W",
                                "Connect to remote web2py debugger")
        self.Bind(wx.EVT_MENU, self.OnAttachWebserver, id=ID_ATTACH)


        # read configuration with safe defaults        
        cfg = wx.GetApp().get_config("WEB2PY")
        path = cfg.get("path", path)
        password = cfg.get("password", password)
        port = cfg.get("port", port)
        host = "127.0.0.1"
        
        if path:           
            # store current directory
            prevdir = os.path.abspath(os.curdir)
           
            try:
                os.chdir(path)
                sys.path.insert(0, path)
                from gluon.main import wsgibase, save_password

                # store admin password
                save_password(password, port)

                # create a wsgi server
                self.web2py_httpd = make_server(host, port, wsgibase)
                print "Serving HTTP on port %s..." % port

                # connect to idle event to poll and serve requests
                ##self.Bind(wx.EVT_IDLE, self.OnIdleServeWeb2py)

                # open internal browser at default page:
                url = "http://%s:%s/" % (host, port)
                if self.browser:
                    #self.browser.LoadURL(url)
                    pass
                else:
                    # no interna browser, open external one
                    try:
                        import webbrowser
                        webbrowser.open(url)
                    except:
                        print 'warning: unable to detect your browser'
                
                web2py_env = self.build_web2py_environment()

                if False:
                    # Start a alternate web2py in a separate thread (for blocking requests)
                    from threading import Thread
                    def f(host, port, password):
                        save_password(password, port)
                        httpd2 = make_server(host, port, wsgibase)
                        print "THREAD - Serving HTTP on port2 %s..." % port
                        httpd2.serve_forever()

                    p = Thread(target=f, args=("127.0.0.1", 8000, password))
                    p.start()                
                
            except Exception, e:
                self.ShowInfoBar(u"cannot start web2py!: %s" % unicode(e), 
                                 flags=wx.ICON_ERROR, key="web2py")
                web2py_env = {}
            finally:
コード例 #15
0
    def load_configuration(self):
        """
        Loads the configuration required to build the command-line string
        for running web2py. Returns a tuple (command_args, config_dict).
        """
        s = os.path.sep

        default = dict(
            python='python',
            web2py=os.path.join(s.join(__file__.split(s)[:-3]), 'web2py.py'),
            http_enabled=True,
            http_ip='0.0.0.0',
            http_port=8000,
            https_enabled=True,
            https_ip='0.0.0.0',
            https_port=8001,
            https_key='',
            https_cert='',
            password='******',
        )

        config = default
        if self.config_file:
            try:
                f = open(self.config_file, 'r')
                lines = f.readlines()
                f.close()

                for line in lines:
                    fields = line.split('=', 1)
                    if len(fields) == 2:
                        key, value = fields
                        key = key.strip()
                        value = value.strip()
                        config[key] = value
            except:
                pass

        web2py_path = os.path.dirname(config['web2py'])
        os.chdir(web2py_path)

        args = [config['python'], config['web2py']]
        interfaces = []
        ports = []

        if config['http_enabled']:
            ip = config['http_ip']
            port = config['http_port']
            interfaces.append('%s:%s' % (ip, port))
            ports.append(port)
        if config['https_enabled']:
            ip = config['https_ip']
            port = config['https_port']
            key = config['https_key']
            cert = config['https_cert']
            if key != '' and cert != '':
                interfaces.append('%s:%s:%s:%s' % (ip, port, cert, key))
                ports.append(ports)
        if len(interfaces) == 0:
            sys.exit(
                'Configuration error. Must have settings for http and/or https'
            )

        password = config['password']
        if not password == '<recycle>':
            from gluon import main
            for port in ports:
                main.save_password(password, port)

            password = '******'

        args.append('-a "%s"' % password)

        interfaces = ';'.join(interfaces)
        args.append('--interfaces=%s' % interfaces)

        if 'log_filename' in config.key():
            log_filename = config['log_filename']
            args.append('--log_filename=%s' % log_filename)

        return (args, config)
コード例 #16
0
ファイル: service.py プロジェクト: CzechErface/web2py
    def load_configuration(self):
        """
        Loads the configuration required to build the command-line string
        for running web2py. Returns a tuple (command_args, config_dict).
        """
        s = os.path.sep

        default = dict(
            python = 'python',
            web2py = os.path.join(s.join(__file__.split(s)[:-3]), 'web2py.py'),
            http_enabled = True,
            http_ip = '0.0.0.0',
            http_port = 8000,
            https_enabled = True,
            https_ip = '0.0.0.0',
            https_port = 8001,
            https_key = '',
            https_cert = '',
            password = '******',
        )

        config = default
        if self.config_file:
            try:
                f = open(self.config_file, 'r')
                lines = f.readlines()
                f.close()

                for line in lines:
                    fields = line.split('=', 1)
                    if len(fields) == 2:
                        key, value = fields
                        key = key.strip()
                        value = value.strip()
                        config[key] = value
            except:
                pass

        web2py_path = os.path.dirname(config['web2py'])
        os.chdir(web2py_path)

        args = [config['python'], config['web2py']]
        interfaces = []
        ports = []

        if config['http_enabled']:
            ip = config['http_ip']
            port = config['http_port']
            interfaces.append('%s:%s' % (ip, port))
            ports.append(port)
        if config['https_enabled']:
            ip = config['https_ip']
            port = config['https_port']
            key = config['https_key']
            cert = config['https_cert']
            if key != '' and cert != '':
                interfaces.append('%s:%s:%s:%s' % (ip, port, key, cert))
                ports.append(ports)
        if len(interfaces) == 0:
            sys.exit('Configuration error. Must have settings for http and/or https')

        password = config['password']
        if not password == '<recycle>':
            from gluon import main
            for port in ports:
                main.save_password(password, port)

            password = '******'

        args.append('-a "%s"' % password)

        interfaces = ';'.join(interfaces)
        args.append('--interfaces=%s' % interfaces)

        if 'log_filename' in config.keys():
            log_filename = config['log_filename']
            args.append('--log_filename=%s' % log_filename)

        return (args, config)
コード例 #17
0
ファイル: ensure_password.py プロジェクト: aduckworth1969/smc
import os
import sys
import getpass

curr_dir = os.path.dirname(os.path.abspath(__file__))

os.chdir(curr_dir)

from gluon.main import save_password

param_file = os.path.join(curr_dir, "parameters_8000.py")

print(param_file)
if os.path.exists(param_file) is True:
    print("PW already set")
    sys.exit()

pw = getpass.getpass("Enter w2py admin password: ")

save_password(pw, 8000)
コード例 #18
0
ファイル: x_fixtures.py プロジェクト: aduckworth1969/smc
    admin_group_id = auth.id_group("Administrators")
    row = db(db.auth_user.username == "admin").select().first()
    admin_id = row["id"]
    auth.add_membership(group_id=admin_group_id, user_id=admin_id)
    db.commit()
new_admin = False

#  Make sure the admin password is setup if we are in a docker container (presence of IT_PW environment variable)
startup = cache.ram('startup', lambda: True, time_expire=600)
if (startup == True):
    # Set password
    from gluon.main import save_password
    pw = ""
    if "IT_PW" in os.environ:
        pw = str(os.environ["IT_PW"]) + ""
        pw = pw.strip()
    if (pw != ""):
        # print("Resetting admin password...")
        # Set pw for w2p admin login (parameters_??.py file)
        save_password(pw, 80)
        save_password(pw, 443)
        # Set pw for smc admin login (in the database)
        db(db.auth_user.username == 'admin').update(
            password=db.auth_user.password.validate(pw)[0])
        db.commit()
    # Set the cache with the new value
    cache.ram('startup', lambda: False, 0)

if db_init_needed:
    # Mark that we did it so we quit doing it on every page view
    cache.ram('db_init_needed', lambda: False, 0)