コード例 #1
0
ファイル: IDS.py プロジェクト: attocube-systems/IDS-APIs
    def __init__(self, address):

        super().__init__(address)

        self.about = About(self)
        self.access = Access(self)
        self.adjustment = Adjustment(self)
        self.axis = Axis(self)
        self.displacement = Displacement(self)
        self.ecu = Ecu(self)
        self.functions = Functions(self)
        self.manual = Manual(self)
        self.network = Network(self)
        self.nlc = Nlc(self)
        self.pilotlaser = Pilotlaser(self)
        self.realtime = Realtime(self)
        self.system = System(self)
        self.system_service = System_service(self)
        self.update = Update(self)
        try:
            self.streaming = Streaming(self)
        except NameError as e:
            if "Streaming" in str(e):
                print("Warning: Streaming is not supported on your platform")
            else:
                raise e
コード例 #2
0
    def __init__(self,DEBUG=False):

        self._stop = threading.Event()
        self._interval = 1

        self.DEBUG = DEBUG
        self.access = Access()
コード例 #3
0
    def __init__(self, downloaddir='./downloads', entityid=None, DEBUG=False):
        #threading.Thread.__init__(self)

        self._stop = threading.Event()
        self._interval = 1

        self.downloaddir = downloaddir
        self.entityid = entityid
        self.DEBUG = DEBUG

        if self.DEBUG:
            if self.entityid != None:
                print "Using conditional EntityID."

        self.unpdfer = Unpdfer()

        #self.searchapi = Search()
        self.myid = str(uuid.uuid4())
        self.dbaccess = Access(DEBUG=True)

        # setup access layer
        #self.myid = str(uuid.uuid4())
        #self.busaccess = BusAccess(myid=self.myid,DEBUG=True)
        #self.busaccess.setcallback(self._callback)

        # start seperate thread with listener in it
        #self.listenthread = threading.Thread(target=self.busaccess.listen)
        #self.listenthread.start()

        if self.DEBUG:
            print "Converter INIT completed successfully."
コード例 #4
0
ファイル: mm_web.py プロジェクト: thequbit/monroeminutes
def addorg():

    if not ADMIN:
        return ''
    """
    org = {
        'name': 'Brighton Town Board',
        'description': 'Brighton, NY Town Board',
        'matchs': [
            'town board',
            'brighton',
        ]
        'entityid': ObjectID(' ... '),
        'creationdatetime': '2014-03-14 22:01:30',
    }
    """

    success = True
    try:

        try:
            org = json.loads(request.args['org'])
        except:
            org = None

        if org != None:
            access = Access()
            access.addorg(org)
        else:
            success = False

    except:
        success = False

    return json.dumps({'success': success})
コード例 #5
0
ファイル: mm_web.py プロジェクト: thequbit/monroeminutes
def addentity():

    if not ADMIN:
        return ''
    """
    entity = {
        'name':'Brighton, NY',
        'description':'Town of Brighton, NY',
        'website':'http://www.townofbrighton.org/',
        'creationdatetime':'2014-02-23 21:24:26',
    }

    """

    success = True
    try:

        try:
            entity = json.loads(request.args['entity'])
        except:
            entity = None

        if entity != None:
            access = Access()
            access.addentity(entity)
        else:
            success = False

    except:
        success = False

    return json.dumps({'success': success})
コード例 #6
0
    def test_weighted_catchment_with_gravity_weights(self):
        n = 5
        supply_grid = tu.create_nxn_grid(n)
        demand_grid = supply_grid
        cost_matrix = tu.create_cost_matrix(supply_grid, 'euclidean')

        self.model = Access(demand_df=demand_grid,
                            demand_index='id',
                            demand_value='value',
                            supply_df=supply_grid,
                            supply_index='id',
                            supply_value='value',
                            cost_df=cost_matrix,
                            cost_origin='origin',
                            cost_dest='dest',
                            cost_name='cost')

        gravity = weights.gravity(scale=60, alpha=1)
        self.model.weighted_catchment(name='gravity', weight_fn=gravity)

        ids = [1, 5, 13, 19, 24]
        expected_vals = [
            1.322340210,
            1.322340210,
            0.780985109,
            0.925540119,
            1.133733026,
        ]

        for id, expected in zip(ids, expected_vals):
            actual = self.model.access_df.gravity_value.loc[id]

            self.assertAlmostEqual(actual, expected)
コード例 #7
0
def copy_img_match(dbpath, hospitname, srcfield, imgdir, destdir):
    ObjSql = SqlAccess()
    objDB = Access(dbpath)
    # dirs = glob.glob
    sqls = r" SELECT DISTINCT t.%s FROM %s AS t " % (srcfield,
                                                     TABLENAME[hospitname])
    paths = ""
    if not objDB.sql_excute(sqls):
        RunError(objDB, sqls)
    emptycnt = 0
    nofilecnt = 0
    cnt = 0
    allcnt = 0
    while True:
        allcnt += 1
        row = objDB.sql_cur_fetchone()
        if not row:
            print("error in row")
            break
        applynostr = row[0]
        dirs = os.path.join(imgdir, applynostr)
        paths = glob.glob(dirs)
        if len(paths) == 0 or len(paths) == 2:
            tstr = " %s not exist or multipy %d" % (dirs, len(paths))
            print(tstr)
            s1 = tstr.encode("utf-8")
            # regexlog.info(s1)
            regexlog.info("%s not or multipy" % applynostr)
            emptycnt += 1
            continue

        if 0 == len(os.listdir(paths[0])):
            tstr = "%s have no file" % paths[0]
            print(tstr)
            s1 = tstr.encode("utf-8")
            # regexlog.info(s1)
            regexlog.info("%s null" % applynostr)
            nofilecnt += 1
            continue
        else:
            tstr = " %s have files " % paths[0]
            s1 = tstr.encode("utf-8")
            # regexlog.info(s1)
            regexlog.info("%s ok" % applynostr)
            cnt += 1
            srcpath = paths[0]
            destpath = os.path.join(destdir, applynostr)
            if os.path.isdir(destpath):
                logtime = time.strftime("%Y%m%d%H%M%S",
                                        time.localtime(time.time()))
                destpath += '_' + logtime
                regexlog.info(destpath)
            shutil.copytree(srcpath, destpath)
        if 0 == (allcnt % 100):
            print(allcnt)
    objDB.dbclose()
    tstr = "no file %d, empty file %d, have file %d, allfile %d" % (
        emptycnt, nofilecnt, cnt, allcnt)
    regexlog.info(tstr)
    print(tstr)
コード例 #8
0
ファイル: mm_web.py プロジェクト: thequbit/monroeminutes
def searches():

    try:
        access = Access()
        results = access.getsearches()
    except:
        results = []

    return json.dumps(results)
コード例 #9
0
ファイル: mm_web.py プロジェクト: thequbit/monroeminutes
def statuses():
    try:
        access = Access()
        statuses = access.getstatuses()
        for i in range(0, len(statuses)):
            statuses[i]['_id'] = str(statuses[i]['_id'])
    except:
        statuses = []
    return json.dumps(statuses)
コード例 #10
0
ファイル: mm_web.py プロジェクト: thequbit/monroeminutes
def getdoc():
    try:
        docurl = request.args['docurl']
        access = Access()
        doc = access.getdoc(docurl)
        if doc == None:
            doc = {}
    except:
        doc = {}
    return json.dumps(doc)
コード例 #11
0
    def __init__(self,
                 address='localhost',
                 exchange='monroeminutes',
                 DEBUG=False):

        self.dispatcher = Dispatcher(address=address,
                                     exchange=exchange,
                                     DEBUG=DEBUG)
        self.access = Access()

        self.urls = []
コード例 #12
0
ファイル: test_access.py プロジェクト: yeejinhyung/access
    def test_access_initialize_without_supply_value_col_in_list_raises_value_error(
            self):
        with self.assertRaises(ValueError):
            bad_value_name = ['Not a col in supply df']

            Access(demand_df=self.demand_grid,
                   demand_index='id',
                   demand_value='value',
                   supply_df=self.supply_grid,
                   supply_index='id',
                   supply_value=bad_value_name)
コード例 #13
0
ファイル: test_access.py プロジェクト: yeejinhyung/access
    def test_access_initialize_with_supply_value_col_in_dict_raises_value_error(
            self):
        with self.assertRaises(ValueError):
            value_in_dict = {'value': ''}

            self.model = Access(demand_df=self.demand_grid,
                                demand_index='id',
                                demand_value='value',
                                supply_df=self.supply_grid,
                                supply_index='id',
                                supply_value=value_in_dict)
コード例 #14
0
ファイル: test_access.py プロジェクト: yeejinhyung/access
    def test_access_initialize_without_demand_index_col_raises_value_error(
            self):
        with self.assertRaises(ValueError):
            bad_index_name = 'Not a col in demand df'

            Access(demand_df=self.demand_grid,
                   demand_index=bad_index_name,
                   demand_value='value',
                   supply_df=self.supply_grid,
                   supply_index='id',
                   supply_value='value')
コード例 #15
0
ファイル: test_access.py プロジェクト: yeejinhyung/access
    def test_access_initialize_with_supply_value_col_in_list(self):
        value_in_list = ['value']

        self.model = Access(demand_df=self.demand_grid,
                            demand_index='id',
                            demand_value='value',
                            supply_df=self.supply_grid,
                            supply_index='id',
                            supply_value=value_in_list)

        actual = self.model.supply_types

        self.assertEqual(actual, ['value'])
コード例 #16
0
ファイル: test_raam.py プロジェクト: yeejinhyung/access
    def setUp(self):
        n = 5
        supply_grid = tu.create_nxn_grid(n)
        demand_grid = supply_grid.sample(1)
        cost_matrix = tu.create_cost_matrix(supply_grid, 'euclidean')

        self.model = Access(demand_df = demand_grid, demand_index = 'id',
                            demand_value = 'value',
                            supply_df = supply_grid, supply_index = 'id',
                            supply_value = 'value',
                            cost_df   = cost_matrix, cost_origin  = 'origin',
                            cost_dest = 'dest',      cost_name = 'cost',
                            neighbor_cost_df   = cost_matrix, neighbor_cost_origin  = 'origin',
                            neighbor_cost_dest = 'dest',      neighbor_cost_name = 'cost')
コード例 #17
0
ファイル: mm_web.py プロジェクト: thequbit/monroeminutes
def getdocs():
    """
    doc = {
        "scrapedatetime": "2014-02-22 03:25:49",
        "docfilename": "/home/administrator/dev/monroeminutes/downloads//4028_1393057549.41.download",
        "being_processed": false,
        "being_converted": true,
        "pdfhash": "",
        "docurl": "http://www.townofbrighton.org/DocumentCenter/View/4028",
        "linktext": "View here",
        "converted": false,
        "pdftext": "",
        "_id": "53085f0ea70f9e0e63aeb15a",
        "urldata": {
            "maxlinklevel": 4,
            "status": "running",
            "runs": [],
            "description": "Brighton, NY",
            "title": "Town of Brighton",
            "scraperid": "2aeaa63f-bef9-4362-a7b3-e8c6c6a92913",
            "doctype": "application/pdf",
            "frequency": 604800,
            "startdatetime": "2014-02-22 03:25:31",
            "targeturl": "http://www.townofbrighton.org/",
            "finishdatetime": "",
            "creationdatetime": "2014-02-22 03:25:09"
        },
        "processed": false
    }
    """

    try:
        access = Access()

        try:
            entityid = request.args['entityid']
        except:
            entityid = ''

        if entityid != '':
            docs = access.getdocsbyentityid(entityid)
            for i in range(0, len(docs)):
                docs[i]['_id'] = str(docs[i]['_id'])
                docs[i]['created'] = str(docs[i]['created'])
        else:
            docs = []
    except:
        docs = []

    return json.dumps(docs)
コード例 #18
0
ファイル: test_access.py プロジェクト: yeejinhyung/access
    def test_access_initialize_with_valid_neighbor_cost_name_in_dict_raises_value_error(
            self):
        with self.assertRaises(ValueError):
            cost_name_dict = {'cost': ''}

            self.model = Access(demand_df=self.demand_grid,
                                demand_index='id',
                                demand_value='value',
                                supply_df=self.supply_grid,
                                supply_index='id',
                                supply_value='value',
                                neighbor_cost_df=self.cost_matrix,
                                neighbor_cost_origin='origin',
                                neighbor_cost_dest='dest',
                                neighbor_cost_name=cost_name_dict)
コード例 #19
0
ファイル: test_access.py プロジェクト: yeejinhyung/access
    def test_access_initialize_without_valid_cost_dest_raises_value_error(
            self):
        with self.assertRaises(ValueError):
            bad_cost_dest = "Not a valid cost dest column"

            Access(demand_df=self.demand_grid,
                   demand_index='id',
                   demand_value='value',
                   supply_df=self.supply_grid,
                   supply_index='id',
                   supply_value='value',
                   cost_df=self.cost_matrix,
                   cost_origin='origin',
                   cost_dest=bad_cost_dest,
                   cost_name='cost')
コード例 #20
0
ファイル: test_access.py プロジェクト: yeejinhyung/access
    def test_access_initialize_without_valid_neighbor_cost_name_in_list_raises_value_error(
            self):
        with self.assertRaises(ValueError):
            bad_cost_name = ["Not a valid cost name column"]

            Access(demand_df=self.demand_grid,
                   demand_index='id',
                   demand_value='value',
                   supply_df=self.supply_grid,
                   supply_index='id',
                   supply_value='value',
                   neighbor_cost_df=self.cost_matrix,
                   neighbor_cost_origin='origin',
                   neighbor_cost_dest='dest',
                   neighbor_cost_name=bad_cost_name)
コード例 #21
0
def login():
    connection = mysql.connector.connect(user=os.getenv("DB_USER"),
                                         password=os.getenv("DB_PASS"),
                                         host=os.getenv("DB_HOST"),
                                         database=os.getenv("DB_NAME"))
    cursor = connection.cursor()
    login_access = Access(connection, cursor)
    electoral_key = request.form.get('electoral_key')
    password = request.form.get('pass')
    response = make_response(
        json.dumps(login_access.login(str(electoral_key), str(password))))
    response.headers['Access-Control-Allow-Origin'] = '*'
    response.headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
    response.headers['Access-Control-Allow-Headers'] = 'Content-Type'
    connection.close()
    return response
コード例 #22
0
def show_applyno_match_ZD(dbpath, hospitname, imgdir):
    ObjSql = SqlAccess()
    objDB = Access(dbpath)
    # dirs = glob.glob
    sqls = r" SELECT DISTINCT t.ApplyNo FROM %s AS t " % TABLENAME[hospitname]
    paths = ""
    if not objDB.sql_excute(sqls):
        RunError(objDB, sqls)
    emptycnt = 0
    nofilecnt = 0
    cnt = 0
    while True:
        row = objDB.sql_cur_fetchone()
        if not row:
            print("error in row")
            break
        applynostr = row['applyno']
        dirs = os.path.join(imgdir, applynostr)
        paths = glob.glob(dirs)
        if len(paths) == 0 or len(paths) == 2:
            tstr = " %s not exist or multipy %d" % (dirs, len(paths))
            print(tstr)
            s1 = tstr.encode("utf-8")
            # regexlog.info(s1)
            regexlog.info("%s not or multipy" % applynostr)
            emptycnt += 1
            continue

        if 0 == len(os.listdir(paths[0])):
            tstr = "%s have no file" % paths[0]
            print(tstr)
            s1 = tstr.encode("utf-8")
            # regexlog.info(s1)
            regexlog.info("%s null" % applynostr)
            nofilecnt += 1
            continue
        else:
            tstr = " %s have files " % paths[0]
            s1 = tstr.encode("utf-8")
            # regexlog.info(s1)
            regexlog.info("%s ok" % applynostr)
            cnt += 1
    objDB.dbclose()
    tstr = "empty file %d, no file %d, have file %d" % (emptycnt, nofilecnt,
                                                        cnt)
    regexlog.info(tstr)
    print(tstr)
コード例 #23
0
def signup():
    connection = mysql.connector.connect(user=os.getenv("DB_USER"),
                                         password=os.getenv("DB_PASS"),
                                         host=os.getenv("DB_HOST"),
                                         database=os.getenv("DB_NAME"))
    cursor = connection.cursor()
    signup_access = Access(connection, cursor)
    electoral_key = request.form.get('electoral_key')
    password = request.form.get('pass')
    mail = request.form.get('email')
    response = make_response(
        str(
            signup_access.register(str(electoral_key), str(password),
                                   str(mail))))
    response.headers.add('Access-Control-Allow-Origin', '*')
    connection.close()
    return response
コード例 #24
0
ファイル: test_access.py プロジェクト: yeejinhyung/access
    def test_access_initialize_with_valid_neighbor_cost_name_in_list(self):
        cost_name_list = ['cost']

        self.model = Access(demand_df=self.demand_grid,
                            demand_index='id',
                            demand_value='value',
                            supply_df=self.supply_grid,
                            supply_index='id',
                            supply_value='value',
                            neighbor_cost_df=self.cost_matrix,
                            neighbor_cost_origin='origin',
                            neighbor_cost_dest='dest',
                            neighbor_cost_name=cost_name_list)

        actual = self.model.neighbor_cost_names

        self.assertEqual(actual, ['cost'])
コード例 #25
0
    def setUp(self):
        demand_data = pd.DataFrame({
            'id': [0, 1],
            'x': [0, 0],
            'y': [0, 1],
            'value': [1, 1]
        })
        demand_grid = gpd.GeoDataFrame(demand_data,
                                       geometry=gpd.points_from_xy(
                                           demand_data.x, demand_data.y))
        demand_grid['geometry'] = demand_grid.buffer(.5)

        supply_data = pd.DataFrame({
            'id': [1],
            'x': [0],
            'y': [1],
            'value': [1]
        })
        supply_grid = gpd.GeoDataFrame(supply_data,
                                       geometry=gpd.points_from_xy(
                                           supply_data.x, supply_data.y))

        cost_matrix = pd.DataFrame({
            'origin': [0, 0, 1, 1],
            'dest': [1, 0, 0, 1],
            'cost': [1, 0, 1, 0]
        })

        self.model = Access(demand_df=demand_grid,
                            demand_index='id',
                            demand_value='value',
                            supply_df=supply_grid,
                            supply_index='id',
                            supply_value='value',
                            cost_df=cost_matrix,
                            cost_origin='origin',
                            cost_dest='dest',
                            cost_name='cost',
                            neighbor_cost_df=cost_matrix,
                            neighbor_cost_origin='origin',
                            neighbor_cost_dest='dest',
                            neighbor_cost_name='cost')
コード例 #26
0
    def __init__(self, address):

        super().__init__(address)

        self.about = About(self)
        self.access = Access(self)
        self.amcids = Amcids(self)
        self.control = Control(self)
        self.description = Description(self)
        self.diagnostic = Diagnostic(self)
        self.functions = Functions(self)
        self.move = Move(self)
        self.network = Network(self)
        self.res = Res(self)
        self.rotcomp = Rotcomp(self)
        self.rtin = Rtin(self)
        self.rtout = Rtout(self)
        self.status = Status(self)
        self.system_service = System_service(self)
        self.update = Update(self)
コード例 #27
0
ファイル: mm_archiver.py プロジェクト: thequbit/monroeminutes
    def __init__(self,
                 address='localhost',
                 exchange='monroeminutes',
                 downloaddir="./downloads",
                 DEBUG=False):

        self.exchange = exchange
        self.downloaddir = downloaddir
        self.DEBUG = DEBUG

        self.access = Access()

        #setup message bus
        self.reqcon = pika.BlockingConnection(
            pika.ConnectionParameters(host=address))
        self.reqchan = self.reqcon.channel()
        self.reqchan.exchange_declare(exchange=self.exchange, type='fanout')
        result = self.reqchan.queue_declare(exclusive=True)
        queue_name = result.method.queue
        self.reqchan.queue_bind(exchange=self.exchange, queue=queue_name)
        self.reqchan.basic_consume(self.reqcallback,
                                   queue=queue_name,
                                   no_ack=True)
コード例 #28
0
#!/usr/bin/python

from pool import Pool
from input_output import IO
from labyrinth import Labyrinth
from access import Access

pool = Pool()
pool.fill()

io = IO()
labyrinth = Labyrinth()
access = Access()
io.fill()
labyrinth.fill()
access.fill()

while True:
    labyrinth.process(pool)
    access.process(pool)
    io.process(pool)
コード例 #29
0
from access import Access

if __name__ == '__main__':
    
    print "Resetting database flags ..."

    a = Access()

    a._resetstates()

    print "Done."
コード例 #30
0
ファイル: liu.py プロジェクト: wenzhilv/SelfDataMining_sql
        sqls = ObjSql.get_sql_update(desttable, fielddestinstate, finstr, ['patientid', 'visitid'], [row['patientid'], row['visitid']])
        if not objdb.sql_update(sqls):
            errstr = " %s error " % sqls
            RunError(objdb, errstr)
        sqls = ObjSql.get_sql_update(desttable, fielddestoutstate, foutstr, ['patientid', 'visitid'],
                                     [row['patientid'], row['visitid']])
        if not objdb.sql_update(sqls):
            errstr = " %s error " % sqls
            RunError(objdb, errstr)
        sqls = ObjSql.get_sql_update(desttable, fielddestApgar, *, ['patientid', 'visitid'],
                                     [row['patientid'], row['visitid']])
        if not objdb.sql_update(sqls):
            errstr = " %s error " % sqls
            RunError(objdb, errstr)
        sqls = ObjSql.get_sql_update(desttable, fielddestNT, *, ['patientid', 'visitid'],
                                     [row['patientid'], row['visitid']])
        if not objdb.sql_update(sqls):
            errstr = " %s error " % sqls
            RunError(objdb, errstr)



if __name__ == '__main__':
    print('start liu')
    dbsrc = r"D:\lwz\softproject\py\process data\fck-trszyc\python process\Localsrctmp.mdb"
    objDB = Access(dbsrc)
    # get_NT_value3(objDB)
    get_ntAndapgar_Discharge(objDB)
    objDB.dbclose()
    print('end liu')