rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.sent_message.remove(message_id)
self.sent_messages.remove(message_id)
def _on_transaction_response(self, message_id, response): if message_id in self.sent_messages and response.code != 200: self.sent_message.remove(message_id) data = TimestampedNotificationData(message_id=message_id, message=response, code=response.code, reason=response.comment) NotificationCenter().post_notification('Ch...
"patches/portaudio-pa_linux_alsa.c_pulse_1.patch", "patches/portaudio-pa_linux_alsa.c_pulse_2.patch"]
"patches/portaudio-1420-compile_snow_leopard.patch", "patches/portaudio-1420-pa_mac_core_x64_assert_fix.patch"]
def get_svn_revision(svn_dir, max_revision=None): environment = dict((name, value) for name, value in os.environ.iteritems() if name!='LANG' and not name.startswith('LC_')) environment['LC_ALL'] = 'C' if max_revision is None: svn_info = distutils_exec_process(["svn", "info", svn_dir], True, env=environment) else: svn_i...
self.portaudio_svn_revision = os.environ.get("PORTAUDIO_SVN_REVISION", "1433")
self.portaudio_svn_revision = os.environ.get("PORTAUDIO_SVN_REVISION", "1412")
def initialize_options(self): build_ext.initialize_options(self) self.pjsip_clean_compile = 0 self.pjsip_disable_assertions = int(os.environ.get("PJSIP_NO_ASSERT", 0)) self.pjsip_svn_revision = os.environ.get("PJSIP_SVN_REVISION", "HEAD") self.pjsip_build_dir = os.environ.get("PJSIP_BUILD_DIR", None) self.pjsip_svn_rep...
if platform.mac_ver()[0].startswith('10.6'):
if platform.mac_ver()[0].startswith('10.6') and not platform.python_version().startswith('2.5'):
def configure_pjsip(self): log.info("Configuring PJSIP") cflags = "-O3 -fPIC" if sys.platform == "darwin": if platform.mac_ver()[0].startswith('10.6'): cflags += " -arch i386 -arch x86_64" else: cflags += " -arch ppc -arch i386" if self.pjsip_disable_assertions: cflags += " -DNDEBUG" env = os.environ.copy() env['CFLAGS...
cflags += " -arch ppc -arch i386"
cflags += " -arch i386 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"
def configure_pjsip(self): log.info("Configuring PJSIP") cflags = "-O3 -fPIC" if sys.platform == "darwin": if platform.mac_ver()[0].startswith('10.6'): cflags += " -arch i386 -arch x86_64" else: cflags += " -arch ppc -arch i386" if self.pjsip_disable_assertions: cflags += " -DNDEBUG" env = os.environ.copy() env['CFLAGS...
if not account.enabled:
if account is not None and not account.enabled:
def _set_default_account(self, account): if not account.enabled: raise ValueError("account %s is not enabled" % account.id) settings = SIPSimpleSettings() old_account = self.accounts.get(settings.default_account, None) if account is old_account: return if account is None: settings.default_account = None else: settings....
self.msrp_session.send_chunk(chunk, response_cb=lambda response: self._on_transaction_response(message_id, response))
self.msrp_session.send_chunk(chunk, response_cb=partial(self._on_transaction_response, message_id))
def _message_queue_handler(self): notification_center = NotificationCenter() while True: message_id, message, content_type, failure_report, success_report, notify_progress = self.message_queue.wait() if self.msrp_session is None: # should we generate ChatStreamDidNotDeliver per each message in the queue here? break chu...
expected_transport = 'TCP/TLS/MSRP' if SIPSimpleSettings().msrp.transport=='tls' else 'TCP/MSRP'
expected_transport = 'TCP/TLS/MSRP' if isinstance (account, Account) and SIPSimpleSettings().msrp.transport=='tls' else 'TCP/MSRP'
def new_from_sdp(cls, account, remote_sdp, stream_index): remote_stream = remote_sdp.media[stream_index] if remote_stream.media != 'message' or 'file-selector' not in remote_stream.attributes: raise UnknownStreamError expected_transport = 'TCP/TLS/MSRP' if SIPSimpleSettings().msrp.transport=='tls' else 'TCP/MSRP' if re...
expected_transport = 'TCP/TLS/MSRP' if SIPSimpleSettings().msrp.transport=='tls' else 'TCP/MSRP'
expected_transport = 'TCP/TLS/MSRP' if isinstance (account, Account) and SIPSimpleSettings().msrp.transport=='tls' else 'TCP/MSRP'
def new_from_sdp(cls, account, remote_sdp, stream_index): remote_stream = remote_sdp.media[stream_index] if remote_stream.media != 'application': raise UnknownStreamError accept_types = remote_stream.attributes.getfirst('accept-types', None) if accept_types is None or 'application/x-rfb' not in accept_types.split(): ra...
self.transport = setting.msrp.transport
self.transport = settings.msrp.transport
def initialize(self, session, direction): self.greenlet = api.getcurrent() settings = SIPSimpleSettings() notification_center = NotificationCenter() notification_center.add_observer(self, sender=self) try: self.session = session outgoing = direction=='outgoing' if (outgoing and self.account.nat_traversal.use_msrp_relay...
route = notification.data.route message = '%s Registered contact "%s" for sip:%s at %s:%d;transport=%s (expires in %d seconds).\n' % (datetime.now().replace(microsecond=0), notification.data.contact_header.uri, self.account.id, route.address, route.port, route.transport, notification.data.expires)
contact_header = notification.data.contact_header
def _NH_SIPAccountRegistrationDidSucceed(self, notification): if self.registration_succeeded: return route = notification.data.route message = '%s Registered contact "%s" for sip:%s at %s:%d;transport=%s (expires in %d seconds).\n' % (datetime.now().replace(microsecond=0), notification.data.contact_header.uri, self.acc...
if notification.data.registration is not None: route = notification.data.route if notification.data.next_route: next_route = notification.data.next_route next_route_text = 'Trying next route %s:%d;transport=%s.' % (next_route.address, next_route.port, next_route.transport) else: next_route_text = 'No more routes to try...
self.output.put('%s Failed to register contact for sip:%s: %s (retrying in %.2f seconds)\n' % (datetime.now().replace(microsecond=0), self.account.id, notification.data.error, notification.data.timeout))
def _NH_SIPAccountRegistrationDidFail(self, notification): if notification.data.registration is not None: route = notification.data.route if notification.data.next_route: next_route = notification.data.next_route next_route_text = 'Trying next route %s:%d;transport=%s.' % (next_route.address, next_route.port, next_rout...
return hash((self.host, self.port, self.transport))
return hash((self.host, self.port))
def __hash__(self): return hash((self.host, self.port, self.transport))
if self.greenlet is None: self.greenlet = initial_greenlet = api.getcurrent() else: initial_greenlet = None try: handler = getattr(self, '_NH_%s' % notification.name, None) if handler is not None: handler(notification) finally: if self.greenlet is initial_greenlet: self.greenlet = None
handler = getattr(self, '_NH_%s' % notification.name, None) if handler is not None: handler(notification)
def handle_notification(self, notification): if self.greenlet is None: self.greenlet = initial_greenlet = api.getcurrent() else: initial_greenlet = None try: handler = getattr(self, '_NH_%s' % notification.name, None) if handler is not None: handler(notification) finally: if self.greenlet is initial_greenlet: self.gree...
if self.greenlet is not None and self.greenlet is not api.getcurrent():
if self.greenlet is not None:
def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None and self.greenlet is not api.getcurrent(): if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(...
if notification.data.state == 'connected' and notification.data.sub_state == 'received_proposal': self.state = 'received_proposal' try: proposed_remote_sdp = self._invitation.sdp.proposed_remote active_remote_sdp = self._invitation.sdp.active_remote for stream in self.streams: if not stream.validate_update(proposed_rem...
self.greenlet = api.getcurrent() try: if notification.data.state == 'connected' and notification.data.sub_state == 'received_proposal': self.state = 'received_proposal' try: proposed_remote_sdp = self._invitation.sdp.proposed_remote active_remote_sdp = self._invitation.sdp.active_remote for stream in self.streams: if n...
def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None and self.greenlet is not api.getcurrent(): if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(...
self._invitation.send_response(488, extra_headers=[WarningHeader(399, engine.user_agent, 'Failed to update media stream index %d' % stream.index)]) self.state = 'connected'
self._invitation.send_response(488, extra_headers=[WarningHeader(399, engine.user_agent, 'Both removing AND adding a media stream is currently not supported')])
def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None and self.greenlet is not api.getcurrent(): if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(...
return for attr in ('user', 'net_type', 'address_type', 'address'): if getattr(proposed_remote_sdp, attr) != getattr(active_remote_sdp, attr): engine = Engine() self._invitation.send_response(488, extra_headers=[WarningHeader(399, engine.user_agent, 'Difference in contents of o= line')]) self.state = 'connected' noti...
elif added_media_indexes: self.proposed_streams = [] for index in added_media_indexes: media_stream = proposed_remote_sdp.media[index] if media_stream.port != 0: for stream_type in MediaStreamRegistry(): try: stream = stream_type.new_from_sdp(self.account, proposed_remote_sdp, index) except InvalidStreamError: break ex...
def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None and self.greenlet is not api.getcurrent(): if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(...
self._invitation.send_response(488) notification_center.post_notification('SIPSessionDidProcessTransaction', self, TimestampedNotificationData(originator='remote', method='INVITE', code=488, reason=sip_status_messages[488], ack_received='unknown'))
local_sdp = SDPSession.new(self._invitation.sdp.active_local) local_sdp.version += 1 removed_streams = [stream for stream in self.streams if stream.index in removed_media_indexes] prev_on_hold_streams = set(stream for stream in self.streams if stream.hold_supported and stream.on_hold_by_remote) for stream in removed_st...
def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None and self.greenlet is not api.getcurrent(): if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(...
local_sdp = SDPSession.new(self._invitation.sdp.active_local) local_sdp.version += 1 removed_streams = [stream for stream in self.streams if stream.index in removed_media_indexes] prev_on_hold_streams = set(stream for stream in self.streams if stream.hold_supported and stream.on_hold_by_remote) for stream in removed_st...
self.state = 'connected' elif notification.data.state == 'disconnected': if self.state == 'incoming': self.state = 'terminated' if notification.data.originator == 'remote': notification_center.post_notification('SIPSessionDidProcessTransaction', self, TimestampedNotificationData(originator='remote', method='INVITE', co...
def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None and self.greenlet is not api.getcurrent(): if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(...
self.streams.remove(stream) local_sdp.media[stream.index].port = 0 for stream in self.streams: local_sdp.media[stream.index] = stream.get_local_media(for_offer=False) self._invitation.send_response(200, sdp=local_sdp) for stream in removed_streams:
def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None and self.greenlet is not api.getcurrent(): if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(...
notification_center.post_notification('SIPSessionDidProcessTransaction', self, TimestampedNotificationData(originator='remote', method='INVITE', code=200, reason=sip_status_messages[200], ack_received='unknown')) received_invitation_state = False received_sdp_update = False while not received_sdp_update or not receiv...
self.state = 'terminated' if notification.data.originator == 'remote': notification_center.post_notification('SIPSessionDidProcessTransaction', self, TimestampedNotificationData(originator=notification.data.originator, method=notification.data.method, code=200, reason=sip_status_messages[200])) self.end_time = datetime...
def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None and self.greenlet is not api.getcurrent(): if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(...
contact.name = child.display_name
contact.name = child.display_name.value
def _load_data(self): if not self.resource_lists.supported: return resource_lists = self.resource_lists.content try: oma_buddylist = (child for child in resource_lists if isinstance(child, resourcelists.List) and child.name=='oma_buddylist').next() except StopIteration: # This should never happen as the document is nor...
elif self.enabled and set(['auth.password', 'auth.username', 'sip.outbound_proxy', 'sip.transport_list']).intersection(notification.data.modified): if self.sip.register:
elif self.enabled: if set(['auth.password', 'auth.username', 'sip.outbound_proxy', 'sip.transport_list', 'sip.register_interval']).intersection(notification.data.modified) and self.sip.register:
def _NH_CFGSettingsObjectDidChange(self, notification): # activate/deactivate the account or start/stop/reload the registration process if self._started: if 'enabled' in notification.data.modified: if self.enabled: self._activate() else: self._deactivate() elif self.enabled and 'sip.register' in notification.data.modif...
if self.message_summary.enabled:
if set(['auth.password', 'auth.username', 'sip.outbound_proxy', 'sip.transport_list', 'sip.subscribe_interval']).intersection(notification.data.modified) and self.message_summary.enabled:
def _NH_CFGSettingsObjectDidChange(self, notification): # activate/deactivate the account or start/stop/reload the registration process if self._started: if 'enabled' in notification.data.modified: if self.enabled: self._activate() else: self._deactivate() elif self.enabled and 'sip.register' in notification.data.modif...
elif self.enabled and self.sip.register and 'sip.register_interval' in notification.data.modified: self._registrar.reload_settings() elif self.enabled and self.message_summary.enabled and 'sip.subscribe_interval' in notification.data.modified: self._mwi_handler.activate()
def _NH_CFGSettingsObjectDidChange(self, notification): # activate/deactivate the account or start/stop/reload the registration process if self._started: if 'enabled' in notification.data.modified: if self.enabled: self._activate() else: self._deactivate() elif self.enabled and 'sip.register' in notification.data.modif...
"patches/pjsip-2830-runtime_device_change_detection_wmme.patch"]
"patches/pjsip-2830-runtime_device_change_detection_wmme.patch", "patches/pjsip-2830-fix_crash_with_retry_after_header.patch"]
def get_svn_revision(svn_dir, max_revision=None): environment = dict((name, value) for name, value in os.environ.iteritems() if name!='LANG' and not name.startswith('LC_')) environment['LC_ALL'] = 'C' if max_revision is None: svn_info = distutils_exec_process(["svn", "info", svn_dir], True, env=environment) else: svn_i...
for child in iterator: if child.tag == '{%s}from' % self._xml_namespace: try: self.append((child.text, iterator.next().text))
for first_child in iterator: second_child = iterator.next() if first_child.tag == '{%s}from' % self._xml_namespace and second_child.tag == '{%s}until' % self._xml_namespace: try: self.append((first_child.text, second_child.text))
def _parse_element(self, element, *args, **kwargs): iterator = iter(element) for child in iterator: if child.tag == '{%s}from' % self._xml_namespace: try: self.append((child.text, iterator.next().text)) except: pass
for child in self:
for (from_valid, until_valid) in self:
def _build_element(self, *args, **kwargs): self.element.clear() for child in self: from_elem = etree.SubElement(self.element, '{%s}from' % self._xml_namespace, nsmap=self._xml_application.xml_nsmap) until_elem = etree.SubElement(self.element, '{%s}until' % self._xml_namespace, nsmap=self._xml_application.xml_nsmap)
if not isinstance(value, (Entry, ErroCode)):
if not isinstance(value, (Entry, ErrorCode)):
def _add_item(self, value): if not isinstance(value, (Entry, ErroCode)): raise TypeError("Folder element can only contain Entry or ErrorCode children, got %s instead" % value.__class__.__name__) self._insert_element(value.element) return value
"patches/pjsip-2342-g722-14-bits-conversion.patch",
def get_svn_revision(svn_dir, max_revision=None): environment = dict((name, value) for name, value in os.environ.iteritems() if name!='LANG' and not name.startswith('LC_')) environment['LC_ALL'] = 'C' if max_revision is None: svn_info = distutils_exec_process(["svn", "info", svn_dir], True, env=environment) else: svn_i...
"patches/pjsip-2830-hide_route_header.patch"]
"patches/pjsip-2830-hide_route_header.patch", "patches/pjsip-2830-g722_adaptive_shifting.patch"]
def get_svn_revision(svn_dir, max_revision=None): environment = dict((name, value) for name, value in os.environ.iteritems() if name!='LANG' and not name.startswith('LC_')) environment['LC_ALL'] = 'C' if max_revision is None: svn_info = distutils_exec_process(["svn", "info", svn_dir], True, env=environment) else: svn_i...
elif self.sip.registrer and set(registrar_attributes).intersection(notification.data.modified):
elif self.sip.register and set(registrar_attributes).intersection(notification.data.modified):
def _NH_CFGSettingsObjectDidChange(self, notification): # activate/deactivate the account or start/stop/reload the registration process if self._started: if 'enabled' in notification.data.modified: if self.enabled: self._activate() else: self._deactivate() elif self.enabled: registrar_attributes = ['auth.password', 'au...
proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore()
def save(self, *args, **kwargs): proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore() super(Cluster, self).save(*args, **kwargs)
def delete(self, *args, **kwargs): proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore()
proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore() def delete(self, *args, **kwargs):
def save(self, *args, **kwargs): proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore() super(Cluster, self).save(*args, **kwargs)
proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore()
def save(self, *args, **kwargs): proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore() super(Location, self).save(*args, **kwargs)
def delete(self, *args, **kwargs): proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore()
proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore() def delete(self, *args, **kwargs):
def save(self, *args, **kwargs): proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore() super(Location, self).save(*args, **kwargs)
super(Station, self).save(*args, **kwargs) def delete(self, *args, **kwargs):
def delete(self, *args, **kwargs): super(Station, self).delete(*args, **kwargs)
def save(self, *args, **kwargs): update_station_password(self.number, self.password) proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore() super(Station, self).save(*args, **kwargs)
super(Station, self).delete(*args, **kwargs)
def delete(self, *args, **kwargs): remove_station_password(self.number) proxy = xmlrpclib.ServerProxy(settings.DATASTORE_PROXY) proxy.reload_datastore() super(Station, self).delete(*args, **kwargs)
detector = DetectorHisparc.objects.get(station=station)
detector = (DetectorHisparc.objects .filter(station=station) .latest('startdate'))
def get_cluster_station_list(parent): if parent: clusters = Cluster.objects.filter(parent=parent) else: clusters = Cluster.objects.filter(parent__isnull=True) data = [] for cluster in clusters: c = {} c['name'] = cluster.name c['status'] = 1.0 c['contents'] = get_cluster_station_list(parent=cluster) for station in St...
render_and_save_plot(plot, name, 400, 266)
render_and_save_plot(plot, name, 300, 200)
def create_energy_histogram(slug, coincidences): """Create an energy histogram""" name = 'symposium-energy-%s.png' % slug energies = [x.log_energy for x in coincidences] good_energies = [x.log_energy for x in coincidences.filter(error_estimate__lte=100.)] v1, bins = np.histogram(energies, bins=np.arange(14, 23, 1)) ...
v.low_setting, v.hvgh_setting = ybounds
v.low_setting, v.high_setting = ybounds
def create_core_plot(slug, coincidences): """Create a plot showing analyzed shower cores""" name = 'symposium-cores-%s.png' % slug data = chaco.ArrayPlotData() plot = chaco.Plot(data) x, y, logenergy = get_core_positions(coincidences) data.set_data('x', x) data.set_data('y', y) data.set_data('logenergy', logenergy) ...
render_and_save_plot(plot, name, 400, 400)
render_and_save_plot(plot, name, 300, 300)
def create_core_plot(slug, coincidences): """Create a plot showing analyzed shower cores""" name = 'symposium-cores-%s.png' % slug data = chaco.ArrayPlotData() plot = chaco.Plot(data) x, y, logenergy = get_core_positions(coincidences) data.set_data('x', x) data.set_data('y', y) data.set_data('logenergy', logenergy) ...
render_and_save_plot(plot, name, 400, 400)
render_and_save_plot(plot, name, 300, 300)
def create_star_map(slug, coincidences): """Create a star map showing analyzed shower origins""" name = 'symposium-starmap-%s.png' % slug data = chaco.ArrayPlotData() plot = chaco.Plot(data) lat = np.radians(52.3559179545) lon = 4.95114534876 J2000 = calendar.timegm(datetime.datetime(2000, 1, 1, 12).utctimetuple()) ...
clusters=self.clusters.all()
clusters=self.clusters.filter(parent=None)
def last_cluster_number(self): clusters=self.clusters.all() if clusters: clustermax=cluster.aggregate(Max('number')) return clusters['number__max'] else: return self.number-1000
clustermax=cluster.aggregate(Max('number')) return clusters['number__max']
clustermax=clusters.aggregate(Max('number')) return clustermax['number__max']
def last_cluster_number(self): clusters=self.clusters.all() if clusters: clustermax=cluster.aggregate(Max('number')) return clusters['number__max'] else: return self.number-1000
bins = numpy.linspace(0, high, samples)
bins = numpy.linspace(0, high, samples + 1)
def create_histogram(data, high, samples): if data is None: return [], [] else: values = [] for array in data: bins = numpy.linspace(0, high, samples) hist, bins = numpy.histogram(array, bins=bins) values.append(hist) bins = bins.tolist() values = [x.tolist() for x in values] return bins, values
if station == 7030 or station == 7300: break
if (station == 7030 or station == 7300 or station == 8002 or station == 8013 or station == 8014 or station == 8015): continue
def check_for_updates(): state = GeneratorState.objects.get() if state.check_is_running: return False else: last_check_time = time.mktime(state.check_last_run.timetuple()) check_last_run = datetime.datetime.now() state.check_is_running = True state.save() try: summary = datastore.check_for_new_events(last_check_time)...
view.value_range.high_setting = max([max(x) for x in datasets]) * 1.1
m = max([max(x) for x in datasets]) if m != 0: view.value_range.high_setting = m * 1.1
def create_histogram_plot(bins, values, has_multiple_datasets, bin_axis_title, value_axis_title, log): """Convenience function for creating histogram plots""" if has_multiple_datasets: datasets = values color = colors() else: # simulate multiple datasets datasets = [values] color = monochrome() view = chaco.DataView(...
if not session.in_progress:
if not session.in_progress():
def get_coincidence(request, session_hash, student_name): try: session = AnalysisSession.objects.get(hash=session_hash) except AnalysisSession.DoesNotExist: raise Exception('No such analysis session!') else: if not session.in_progress: raise Exception("Analysis session hasn't started yet or " "is already closed!") if ...
vars(s)[number_of] = num_events
if table == 'events': vars(s)[number_of] = num_events
def check_for_updates(): state = GeneratorState.objects.get() if state.check_is_running: return False else: last_check_time = time.mktime(state.check_last_run.timetuple()) check_last_run = datetime.datetime.now() state.check_is_running = True state.save() try: summary = datastore.check_for_new_events(last_check_time)...
update_config(summary)
num_config = update_config(summary) summary.num_config = num_config
def update_all_histograms(): state = GeneratorState.objects.get() if state.update_is_running: return False else: update_last_run = datetime.datetime.now() state.update_is_running = True state.save() try: for summary in Summary.objects.filter(needs_update=True): if summary.needs_update_events: update_eventtime_histogr...
del root_name, mod_name, mod_path, x, env_var_name
del root_name, mod_name, mod_path, x, env_var_name, ld_open_flags
def version_cmp(x, y): return cmp(version_code(x), version_code(y))
del os, sys, imp, glob
del os, sys, imp, glob, DLFCN
def version_cmp(x, y): return cmp(version_code(x), version_code(y))
sx_current = get_buffer_size()[0]
(sx_current, sy_current) = get_buffer_size()
def main(): # %APPDATA% is not always defined (e.g. when using runas.exe) if 'APPDATA' in os.environ.keys(): APPDATA = '%APPDATA%' else: APPDATA = '%USERPROFILE%\\Application Data' global pycmd_data_dir pycmd_data_dir = expand_env_vars(APPDATA + '\\PyCmd') # Create app data directory structure if not present if not os...
set_console_title(curdir + ' - PyCmd')
set_console_title(title_prefix + curdir + ' - PyCmd')
def main(): # %APPDATA% is not always defined (e.g. when using runas.exe) if 'APPDATA' in os.environ.keys(): APPDATA = '%APPDATA%' else: APPDATA = '%USERPROFILE%\\Application Data' global pycmd_data_dir pycmd_data_dir = expand_env_vars(APPDATA + '\\PyCmd') # Create app data directory structure if not present if not os...
print '\t PyCmd [-c command] | [-k command] | [-h]'
print '\t PyCmd [-t title] ( [-c command] | [-k command] | [-h] )'
def print_usage(): """Print usage information""" print 'Usage:' print '\t PyCmd [-c command] | [-k command] | [-h]' print print '\t\t-c command \tRun command, then exit' print '\t\t-k command \tRun command, then continue to the prompt' print '\t\t-h \t\tShow this help' print print 'Note that you can use \'/\' instead o...
tokens = ['"' + token + '"' if contains_special_char(token) else token for token in sys.argv[arg+1:]]
def main(): # %APPDATA% is not always defined (e.g. when using runas.exe) if 'APPDATA' in os.environ.keys(): APPDATA = '%APPDATA%' else: APPDATA = '%USERPROFILE%\\Application Data' global pycmd_data_dir pycmd_data_dir = expand_env_vars(APPDATA + '\\PyCmd') # Create app data directory structure if not present if not os...
if tokens != []: run_command(tokens)
if rest != []: run_command(rest)
def main(): # %APPDATA% is not always defined (e.g. when using runas.exe) if 'APPDATA' in os.environ.keys(): APPDATA = '%APPDATA%' else: APPDATA = '%USERPROFILE%\\Application Data' global pycmd_data_dir pycmd_data_dir = expand_env_vars(APPDATA + '\\PyCmd') # Create app data directory structure if not present if not os...
tokens = ['"' + token + '"' if contains_special_char(token) else token for token in sys.argv[arg+1:]] if tokens != []: run_command(tokens)
if rest != []: run_command(rest)
def main(): # %APPDATA% is not always defined (e.g. when using runas.exe) if 'APPDATA' in os.environ.keys(): APPDATA = '%APPDATA%' else: APPDATA = '%USERPROFILE%\\Application Data' global pycmd_data_dir pycmd_data_dir = expand_env_vars(APPDATA + '\\PyCmd') # Create app data directory structure if not present if not os...
def getPin(self): """__NATIVE__ return readDigitalPinPy(ppframe); """ pass def getLatch(self): """__NATIVE__ return readDigitalLatchPy(ppframe); """ pass
def get(self): """__NATIVE__ return readDigitalValuePy(ppframe); """ pass
def getVoltage(self): """__NATIVE__ return readAnalogFloatPy(ppframe, 3.3/4096.0); """ pass def getNorm(self): """__NATIVE__ return readAnalogFloatPy(ppframe, 1.0/4096.0); """ pass
def getCode(self): """__NATIVE__ return readAnalogCodePy(ppframe); """ pass
__NATIVE__ return setPwmRatioPy(ppframe);
def __init__(self, freq, isTimer2, oc, ocPin=-1): """__NATIVE__ return configPwmPy(ppframe); """ pass
def setCounts(self, counts): """__NATIVE__ return setPwmCountsPy(ppframe);
def setTime(self, timeUs): """__NATIVE__ return setPwmTimePy(ppframe);
def __init__(self, freq, isTimer2, oc, ocPin=-1): """__NATIVE__ return configPwmPy(ppframe); """ pass
def set(self, servo, pwMs):
def set(self, servo, pwUs):
def __init__(self, isTimer2, oc): """__NATIVE__ return configMultiServoPy(ppframe); """ pass
def __init__(self):
def __init__(self, defaultGetList):
def __init__(self): """__NATIVE__ return initDataXferPy(ppframe); """ pass
_udp_socks = {socket.AF_INET: [], socket.AF_UNIX: []}
if is_win32: _udp_socks = {socket.AF_INET: []} else: _udp_socks = {socket.AF_INET: [], socket.AF_UNIX: []}
def close(self): self.del_channel(_map) self.socket.close()
raise ImportError
def implements(*args): pass
def writelined(self, data): self.writelined = self.connection.writelined self.writelined(data)
def writelines(self, data): self.writelines = self.connection.writelines self.writelines(data)
def writelined(self, data): self.writelined = self.connection.writelined self.writelined(data)
We define a simple handler that just notifies of failed connectioons.
We define a simple handler that just notifies of failed connections.
def test_async_cannot_connect(): """Let's make sure that the connector handles connection failures correctly >>> import threading >>> lock = threading.Lock() >>> _ = lock.acquire() We define a simple handler that just notifies of failed connectioons. >>> class Handler: ... def failed_connect(connection, reason):...
self.bind(addr)
def __init__(self, addr, handler): self.__handler = handler self.__close_handler = None self.__connections = {} asyncore.dispatcher.__init__(self) if isinstance(addr, str): family = socket.AF_UNIX else: family = socket.AF_INET self.create_socket(family, socket.SOCK_STREAM) try: if not is_win32: self.set_reuse_addr() se...
self.bind(addr)
def __init__(self, addr, handler, buffer_size=4096): self.__handler = handler self.__buffer_size = buffer_size asyncore.dispatcher.__init__(self) if isinstance(addr, str): family = socket.AF_UNIX else: family = socket.AF_INET try: self.create_socket(family, socket.SOCK_DGRAM) if not is_win32: self.set_reuse_addr() self...
... connection.write((yield).upper())
... connection.write((yield).upper()+'\n')
... def echo(connection):
>>> size = len(zc.ngi.async._map)
>>> len(zc.ngi.async._map) 2
def failure_to_bind_removes_listener_from_socket_map(): """ First, grab a port: >>> import socket, random >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> for i in range(1000): ... port = random.randint(10000, 30000) ... try: s.bind(('', port)) ... except socket.error: pass ... else: break .....
>>> len(zc.ngi.async._map) == size True
>>> len(zc.ngi.async._map) 2
def failure_to_bind_removes_listener_from_socket_map(): """ First, grab a port: >>> import socket, random >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> for i in range(1000): ... port = random.randint(10000, 30000) ... try: s.bind(('', port)) ... except socket.error: pass ... else: break .....
>>> zc.ngi.async.wait(1) >>> size = len(zc.ngi.async._map)
>>> len(zc.ngi.async._map) 2
def failure_to_bind_removes_listener_from_socket_map(): """ First, grab a port: >>> import socket, random >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> for i in range(1000): ... port = random.randint(10000, 30000) ... try: s.bind(('', port)) ... except socket.error: pass ... else: break .....
>>> zc.ngi.async.wait(1)
... def connected(self, conn):
os.close(r)
if self.fd != r: os.close(r)
def __init__(self, map): r, self.__writefd = os.pipe() asyncore.file_dispatcher.__init__(self, r, map)
self.logger.info("listening on %r", self.addr)
self.logger.info("listening on %r", addr)
def __init__(self, addr, handler): self.__handler = handler self.__close_handler = None self.__connections = {} asyncore.dispatcher.__init__(self) if isinstance(addr, str): family = socket.AF_UNIX else: family = socket.AF_INET self.create_socket(family, socket.SOCK_STREAM) try: if not is_win32: self.set_reuse_addr() se...
self.logger.info("listening on udp %r", self.addr)
self.logger.info("listening on udp %r", addr)
def __init__(self, addr, handler, buffer_size=4096): self.__handler = handler self.__buffer_size = buffer_size asyncore.dispatcher.__init__(self) if isinstance(addr, str): family = socket.AF_UNIX else: family = socket.AF_INET try: self.create_socket(family, socket.SOCK_DGRAM) if not is_win32: self.set_reuse_addr() self...
command = ['pausing_keep', name]
command = ['pausing_keep_force', name]
def _command(self, name, *args): """Send a command to MPlayer.
if name in ['get_property pause', 'key_down_event', 'set_mouse_pos']: command[0] = 'pausing_keep_force'
if name in ['pause', 'stop']: command.pop(0)
def _command(self, name, *args): """Send a command to MPlayer.
def _get_sig(args):
def _gen_sig(args):
def _get_sig(args): sig = [] for i, arg in enumerate(args): if arg.startswith('['): arg = arg.strip('[]') arg = '%s%d=""' % (arg, i) else: arg = '%s%d' % (arg, i) sig.append(arg) sig = ', '.join(sig) params = sig.replace('=""', '') return sig, params
sig, params = cls._get_sig(args)
sig, params = cls._gen_sig(args)
def introspect(cls): """Introspect the MPlayer executable
raw_input()
try: raw_input() except NameError: input()
def publish(self, *args): """Publish data to subscribers
doc = [str(ptype)]
doc = ['Type: ' + str(ptype).split("'")[1]]
def _gen_propdoc(ptype, pmin, pmax, propset): doc = [str(ptype)] if propset is not None and ptype != bool: if pmin != 'No': doc.append('Min: %s' % (pmin, )) if pmax != 'No': doc.append('Max: %s' % (pmax, )) if propset is None: doc.append('* Read-only') return '\n'.join(doc)
local[name] = property(local[name], doc="<type 'str'>\n* Read-only")
local[name] = property(local[name], doc='Type: str\n* Read-only')
def %(name)s(self): return self._query('%(cmd)s')
self.destroyed.connect(self._on_destroy) def __del__(self): self._on_destroy()
@QtCore.pyqtSlot(QtCore.QObject) def on_destroy(obj): self._mplayer.quit() self.destroyed.connect(on_destroy)
def __init__(self, parent=None): super(QPlayerView, self).__init__(parent) self._mplayer = QtPlayer(['-idx', '-fs', '-osdlevel', '0', '-really-quiet', '-msglevel', 'global=6', '-fixed-vo', '-wid', str(self.winId())]) self._mplayer.stdout.hook(self._handle_data) self._mplayer.start() self.destroyed.connect(self._on_dest...
def _on_destroy(self, *args): self._mplayer.quit()
def _on_destroy(self, *args): self._mplayer.quit()
w.destroyed.connect(app.quit)
def _handle_data(self, data): if data.startswith('EOF code'): self.completed.emit()
p.completed.connect(app.quit)
p.completed.connect(app.closeAllWindows)
def _handle_data(self, data): if data.startswith('EOF code'): self.completed.emit()
for x in xrange(dots / 4):
d, m = divmod(dots, 4) for x in xrange(d):
def generate(self): """Generate the continuum from the list of servers.""" capacity = float(sum([x.capacity for x in self.servers])) continuum = [] # generate dots on the continuum depending on the capacity of # each server for server in self.servers: dots = int(self.totaldots * (server.capacity / capacity)) for x in x...
module = __import__(module_name)
module = import_module(module_name)
def get_internal_type(self): return 'CharField'
xpTollFree = '@airs:TollFree' xpConfidential = '@airs:Confidential'
xpTollFree = "../%s/%s" % (xpPhone, '@TollFree') xpConfidential = "../%s/%s" % (xpPhone, '@Confidential')
def parse_phone(self, element): ''' Element paths ''' xpPhone = 'airs:Phone' xpPhoneNumber = 'airs:PhoneNumber' xpReasonWithheld = 'airs:ReasonWithheld' xpExtension = 'airs:Extension' xpDescription = 'airs:Description' xpType = 'airs:Type' xpFunction = 'airs:Function' xpTollFree = '@airs:TollFree' xpConfidential = '@ai...
Column('region_id_id_num', String(50)), Column('region_id_id_str', String(50)), Column('site_service_id', String(50)), Column('region_type', String(50)), Column('region_type_date_collected', DateTime(timezone=True)), Column('region_type_date_effective', DateTime(timezone=True)), Column('region_type_data_collection_stag...
Column('attr_delete', Integer), Column('attr_delete_occurred_date', DateTime(timezone=True)), Column('attr_effective', DateTime(timezone=True)), Column('airs_key', String(50)), Column('airs_name', String(50)), Column('agency_description', String(50)), Column('irs_status', String(50)), Column('source_of_funds', String(5...
def agency_2010_map(self): table_metadata = MetaData(bind=self.pg_db, reflect=True) agency_2010_table = Table( 'agency_2010', table_metadata, Column('id', Integer, primary_key=True), Column('export_index_id', String(50), ForeignKey(Export.c.export_id)), Column('region_id_id_num', String(50)), Column('region_id_id_str',...
self.service_2010_map()
def createMappings(self): self.export_map() self.source_map() self.source_export_link_2010_map() self.region_2010_map() self.agency_2010_map() self.agency_child_2010_map() self.service_group_2010_map() self.license_accreditation_2010_map() self.agency_service_2010_map() self.service_2010_map() self.site_2010_map() self...
self.person_map()
def createMappings(self): self.export_map() self.source_map() self.source_export_link_2010_map() self.region_2010_map() self.agency_2010_map() self.agency_child_2010_map() self.service_group_2010_map() self.license_accreditation_2010_map() self.agency_service_2010_map() self.service_2010_map() self.site_2010_map() self...
self.non_cash_benefits_sub_2010_map()
def createMappings(self): self.export_map() self.source_map() self.source_export_link_2010_map() self.region_2010_map() self.agency_2010_map() self.agency_child_2010_map() self.service_group_2010_map() self.license_accreditation_2010_map() self.agency_service_2010_map() self.service_2010_map() self.site_2010_map() self...
useexisting = True ) table_metadata.create_all() mapper(NonCashBenefits, non_cash_benefits_table) return def agency_service_2010_map(self): table_metadata = MetaData(bind=self.pg_db, reflect=True) agency_service_table = Table( 'agency_service_2010', table_metadata, Column('id', Integer, primary_key=True), Column('agen...
def non_cash_benefits_2010_map(self): table_metadata = MetaData(bind=self.pg_db, reflect=True) non_cash_benefits_table = Table( 'non_cash_benefits_2010', table_metadata, Column('id', Integer, primary_key=True), Column('person_historical_index_id', Integer, ForeignKey(PersonHistorical.c.id)), Column('non_cash_benefit_id...
mapper(NonCashBenefitsSub, non_cash_benefits_sub_table)
mapper(NonCashBenefits, non_cash_benefits_table) return def agency_service_2010_map(self): table_metadata = MetaData(bind=self.pg_db, reflect=True) agency_service_table = Table( 'agency_service_2010', table_metadata, Column('id', Integer, primary_key=True), Column('agency_index_id', Integer, ForeignKey(Agency.c.id)), ...
def non_cash_benefits_sub_2010_map(self): table_metadata = MetaData(bind=self.pg_db, reflect=True) non_cash_benefits_sub_table = Table( 'non_cash_benefits_sub_2010', table_metadata, Column('id', Integer, primary_key=True), Column('person_historical_index_id', Integer, ForeignKey(PersonHistorical.c.id)), Column('non_cas...