コード例 #1
0
ファイル: server.py プロジェクト: Etersoft/Tartarus-core
 def getZone(self, con, name, current):
     cur = self._dbh.execute(con, 'SELECT id FROM domains WHERE name=%s',
                             name)
     result = cur.fetchall()
     if len(result) != 1:
         raise ICore.NotFoundError("Could not locate zone in the database")
     return utils.proxy(I.ZonePrx, current, "DNS-Zone", str(result[0][0]))
コード例 #2
0
ファイル: server.py プロジェクト: Etersoft/Tartarus-core
 def getZones(self, con, current):
     cur = self._dbh.execute(con, 'SELECT id FROM domains')
     result = [
         utils.proxy(I.ZonePrx, current, "DNS-Zone", str(x[0]))
         for x in cur.fetchall()
     ]
     return result
コード例 #3
0
ファイル: server.py プロジェクト: Etersoft/Tartarus-core
 def createZone(self, con, name, soar, current):
     self._dbh.execute(con,
                       'INSERT INTO domains (name, type) VALUES (%s, %s)',
                       name, 'NATIVE')
     # we'll need id later to create proxy
     cur = self._dbh.execute(con, 'SELECT id FROM domains WHERE name=%s',
                             name)
     result = cur.fetchall()
     if len(result) != 1:
         raise ICore.DBError("Zone creation failed"
                             "Could not locate zone in the database")
     n = str(result[0][0])
     cur = self._dbh.execute(
         con, "INSERT INTO records (domain_id, name, type, content)"
         "VALUES (%s, %s, 'SOA', %s)", n, name, utils.soar2str(soar))
     if cur.rowcount != 1:
         raise ICore.DBError("Zone creation failed",
                             "Failed to add SOA Record.")
     con.commit()
     return utils.proxy(I.ZonePrx, current, "DNS-Zone", n)
コード例 #4
0
ファイル: posteriori.py プロジェクト: debrouwere/posteriori
    slopes = rises / runs
    
    runs = [25] + list(runs) + [25]
    slopes = [slopes[0]] + list(slopes) + [slopes[-1]]
    
    intercept = quantiles[0] - runs[0] * slopes[0]
    poly = [intercept]
    for slope, run in zip(slopes, runs):
        start = poly[-1] + slope
        stop = poly[-1] + run * slope
        poly.extend(np.linspace(start, stop, num=run))
    
    return poly


proxied = proxy('distribution')

class RandomVariable(np.ndarray):
    # cf. http://docs.scipy.org/doc/numpy-1.10.1/user/basics.subclassing.html
    # for details on subclassing an ndarray
    def __new__(cls, distribution):
        sample = distribution.rvs(N)
        obj = sample.view(cls)
        obj.distribution = distribution
        return obj

    @proxied
    def rvs(self, n):
        return np.random.choice(self, size=n, replace=True)

    @vectorize
コード例 #5
0
ファイル: api.py プロジェクト: Lobos/wordstore
def get_xml(url):
    resp = make_response(proxy(url).replace('\n', ''))
    resp.mimetype = 'text/xml'
    return resp