本文整理汇总了Python中connector.Connector类的典型用法代码示例。如果您正苦于以下问题:Python Connector类的具体用法?Python Connector怎么用?Python Connector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Connector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupGraphics
def setupGraphics(self):
n1 = Nand2(self, "N1", self.scale1((80, 30))) # Nand Gate
i1 = Inv(self, "I1") # Inverter for n1.A
i2 = Inv(self, "I2") # Inverter for n1.B
# external connectorself. Same depth as xor circuit
i1.align(i1.B, n1.A, -40, -20) # inverter precedes Nand
i2.align(i2.B, n1.B, -40, 20) # inverter precedes Nand
self.A = Connector(self, "A", ((i1.A.x(-20), i1.A.y())))
self.B = Connector(self, "B", ((i2.A.x(-20), i2.B.y())))
self.C = Connector(self, "C", ((n1.C.x( 20), n1.C.y())))
self.output = self.C # who is output
self.gates = (i1, i2, n1)
self.i1, self.i2, self.n1 = (i1, i2, n1)
i1.B.addWire(n1.A)
i2.B.addWire(n1.B)
self.A.addWire(i1.A)
self.B.addWire(i2.A)
n1.C.addWire(self.C)
if self.encapsulated(): # if encapsulated re-work externals
self.A.pos, self.B.pos, self.C.pos = self.scaleM(( 0, 5),
( 0, 35),
(20, 20))
示例2: setUp
def setUp (self):
c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
try:
self.root_password = c.ic.getProperties().getProperty('omero.rootpass')
omero_host = c.ic.getProperties().getProperty('omero.host')
finally:
c.__del__()
blitz = Server.find(host=omero_host)
if blitz is None:
Server.reset()
for s in settings.SERVER_LIST:
server = (len(s) > 2) and unicode(s[2]) or None
Server(host=unicode(s[0]), port=int(s[1]), server=server)
Server.freeze()
blitz = Server.find(server=omero_host)
if len(blitz):
self.server_id = blitz[0].id
connector = Connector(self.server_id, True)
self.rootconn = connector.create_connection('TEST.webadmin', 'root', self.root_password)
if self.rootconn is None or not self.rootconn.isConnected() or not self.rootconn.keepAlive():
raise exceptions.Exception("Cannot connect")
else:
raise exceptions.Exception("'%s' is not on omero.web.server_list" % omero_host)
示例3: test_loginFromForm
def test_loginFromForm(self):
params = {
'username': 'root',
'password': self.root_password,
'server':self.server_id,
'ssl':'on'
}
request = fakeRequest(method="post", params=params)
server_id = request.REQUEST.get('server')
form = LoginForm(data=request.REQUEST.copy())
if form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password']
server_id = form.cleaned_data['server']
is_secure = toBoolean(form.cleaned_data['ssl'])
connector = Connector(server_id, is_secure)
conn = connector.create_connection('OMERO.web', username, password)
if conn is None:
self.fail('Cannot connect')
conn.seppuku()
if conn.isConnected() and conn.keepAlive():
self.fail('Connection was not closed')
else:
errors = form.errors.as_text()
self.fail(errors)
示例4: fill_gen_assign_workshop_attendee
def fill_gen_assign_workshop_attendee():
connector = Connector()
conn = connector.connect(secretpassword)
cursor = conn.cursor()
workshop_attendees = []
cursor.execute("select distinct Attendees.AttendeeID, WorkshopReservations.WReservationID "
"from Attendees "
"inner join Participation on Participation.AttendeeID = Attendees.AttendeeID "
"inner join Reservations on Reservations.ReservationID = Participation.ReservationID "
"inner join WorkshopReservations on WorkshopReservations.ReservationID = Reservations.ReservationID")
row = cursor.fetchone()
while row:
workshop_attendees.append((row[0], row[1]))
row = cursor.fetchone()
filler = Connector()
workshop_attendees_size = len(workshop_attendees)
filler.apply_proc_multi('AssignParticipantToWorkshop', workshop_attendees, workshop_attendees_size)
conn.close()
示例5: fetch_news_by_feed_list
def fetch_news_by_feed_list(self, news_data):
conn = Connector()
for n in news_data['news_items']:
print("INF: Fetching news page for '{}'".format(n['link']))
news_item_page = conn.send_req('GET', url=n['link'])
if news_item_page is None:
continue
self.__get_article_from_html__(n, news_item_page.data)
示例6: main
def main():
config = SafeConfigParser()
config.read(PROPERTIES_FILE)
ctor = Connector(config)
report = ctor.get_result()
prsr = Parser()
prsr.parse(report)
prsr.format()
示例7: loginAsUser
def loginAsUser(self, username, password):
blitz = Server.get(pk=self.server_id)
if blitz is not None:
connector = Connector(self.server_id, True)
conn = connector.create_connection('TEST.webadmin', username, password)
if conn is None or not conn.isConnected() or not conn.keepAlive():
raise Exception("Cannot connect")
return conn
else:
raise Exception("'%s' is not on omero.web.server_list" % self.omero_host)
示例8: __init__
class MainController:
def __init__(self, app):
self.deviceData = DeviceData()
self.view = MainView(None)
self.view.scanForDevices.Bind(wx.EVT_BUTTON, self.ScanForDevices)
self.view.syncActivities.Bind(wx.EVT_BUTTON, self.SyncActivities)
self.view.Bind(wx.EVT_MENU, self.OnAbout, self.view.aboutMenuItem)
self.view.Bind(wx.EVT_MENU, self.OnExit, self.view.exitMenuItem)
self.view.Show()
self.scanner = Scanner()
## TODO Preferences for Selected Scanners
self.scanner.addScanner(AntScanner())
self.connector = Connector()
## TODO Preferences for Selected Connectors
self.connector.addConnector(GarminConnector())
pub.subscribe(self.ScanningStarted, "SCANNING STARTED")
pub.subscribe(self.DeviceDetected, "DEVICE DETECTED")
pub.subscribe(self.ActivityRetrieved, "ACTIVITY RETRIEVED")
pub.subscribe(self.ScanningEnded, "SCANNING ENDED")
pub.subscribe(self.SyncStarted, "SYNC STARTED")
pub.subscribe(self.SyncEnded, "SYNC ENDED")
pub.subscribe(self.LoginSuccesful, "LOGIN SUCCESFUL")
pub.subscribe(self.LoginFailed, "LOGIN FAILED")
pub.subscribe(self.ActivitiesUploaded, "ACTIVITIES UPLOADED")
def ScanForDevices(self, evt):
self.scanner.scan()
def ScanningStarted(self, evt):
self.view.setStatus("Scanning started")
def ScanningEnded(self, evt):
self.view.setStatus("Scanning ended")
def DeviceDetected(self, evt):
self.view.setStatus("Device detected")
def ActivityRetrieved(self, evt):
self.view.setStatus("Retrieved activity")
def SyncActivities(self, evt):
self.connector.sync()
def SyncStarted(self, evt):
self.view.setStatus("Sync started")
def SyncEnded(self, evt):
self.view.setStatus("Sync ended")
def LoginSuccesful(self, evt):
self.view.setStatus("Login Succesful")
def LoginFailed(self, evt):
self.view.setStatus("Login Failed")
def ActivitiesUploaded(self, evt):
self.view.setStatus("Activities Uploaded")
def OnExit(self,e):
self.Close(True)
def OnAbout(self, event):
dlg = wx.MessageDialog( self.view, "A community-developed Linux version of the ANT Agent. Supports Garmin-based fitness devices that communicate either over USB serial or via the ANT USB connector. Developed by Philip Whitehouse, based on work by Braiden Kindt, Gustav Tiger and Collin (cpfair). Copyright 2014", "About ANT Agent for Linux", wx.OK);
dlg.ShowModal()
dlg.Destroy()
示例9: inject_metric
def inject_metric(self,quiet):
if self.value == None:
self.load_value()
if quiet == False:
self.print_metric()
cw = Connector()
retval = cw.inject(self.metricname,self.namespace,self.value,self.units,self.dimensions)
if retval == -1:
sys.stderr.write("\033[91mERROR: Monitor [" + self.monid + "] failed to be injected into CloudWatch.\n")
sys.stderr.write(" -- Check JSON entry and that command is returning proper value and format.\033[0m\n")
示例10: __init__
def __init__(self, p12_path, p12_password, p12_buffer=None, production=True, request_timeout=2.0, proxy=None):
self.connector = Connector(p12_path=p12_path,
p12_password=p12_password,
p12_buffer=p12_buffer,
production=production,
request_timeout=request_timeout,
proxy=proxy)
示例11: __init__
def __init__(self, slave=False, protocol=None, address=None, port=None, target_name=None):
self.config = Configurator()
self.is_connected = False
self.is_slave = slave
self.parameters = None
self.datastream_queue = None
self.datastream_poller = None
self.datastream_collector = None
self.signal_structure = None
# Sets basic configurations
if protocol:
self.config.setAttr("protocol", protocol)
if address:
self.config.setAttr("address", address)
if port:
self.config.setAttr("port", port)
if target_name:
self.config.setAttr("target_name", target_name)
# Initializes connection
self.connection = Connector(self.config)
示例12: setUp
def setUp (self):
c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
try:
self.root_password = c.ic.getProperties().getProperty('omero.rootpass')
self.omero_host = c.ic.getProperties().getProperty('omero.host')
self.omero_port = c.ic.getProperties().getProperty('omero.port')
Server.reset()
Server(host=self.omero_host, port=self.omero_port)
finally:
c.__del__()
self.server_id = 1
connector = Connector(self.server_id, True)
self.rootconn = connector.create_connection('TEST.webadmin', 'root', self.root_password)
if self.rootconn is None or not self.rootconn.isConnected() or not self.rootconn.keepAlive():
raise Exception("Cannot connect")
示例13: __init__
def __init__(self, ip, port, automatic = True, control_buf_size = 32, data_buf_size = 128, \
m_to = 0.01, socket_to = 0.005):
"""
Constructor, initialize the modem and the connector. Connect the
modem to the submerged node
@param self pointer to the class object
@param ip string cointaining the IP address of the TCP server
@param port string with the port of the TCP server socket
@param control_buf_size: int with the control buffer size, in bytes
@param data_buf_size: int with the data buffer size, in bytes
@param m_to: float value time out of the cycle, in [s]
@param socket_to: time out of the socket checking operation, [s]
"""
self.conn = Connector(ip, port, control_buf_size, data_buf_size, socket_to)
self.conn.connect()
self.m_to = m_to
self.status = Modem.Status.IDLE
self.node_status = 0
self.automatic = automatic
self.interpreter = Interpreter()
self.mainPID = os.getpid()
self.error_status = Modem.ErrorDict.NONE
self.commands_queue = "".split(Interpreter.END_COMMAND)
if automatic:
thread.start_new_thread(self.run,())
示例14: __init__
def __init__(self):
# initialize file table
self.maxFiles = 1024
# self.files = [dict(path=None, dirty=False, data=None)] * self.maxFiles
self.files = [None] * self.maxFiles
for i in range(0, self.maxFiles):
self.files[i] = dict(path=None, dirty=False, data=None)
self.conn = Connector()
示例15: clone_repo
def clone_repo(src, dest):
"""
Clone a repository.
Arguments:
src -- URL of to the repository to clone from.
dest -- URL of the target directory of the clone.
Returns:
A clone of the supplied repository.
"""
src_connector = Connector.from_string(src)
with src_connector.connected():
origin = repo.Repo.load_from_disk(src_connector)
dest = os.path.join(dest, origin.name) # make clone at "<dest>/<name>"
dest_connector = Connector.from_string(dest)
with dest_connector.connected():
clone = repo.Repo.clone(origin, dest_connector)
init_repo_logging(clone)
log.info("Cloned repository from %s to %s" % (src, dest))
return clone