rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
d3 = Donut(100, 50, inset = 5, offset = (100, 100), rotation = math.pi / 3) print '\Donut(100, 50, (100, 100), math.pi / 3)'
d3 = Donut(1000, 500, inset = 20, offset = (100, 100), rotation = math.pi / 3) print '\Donut(1000, 500, inset = 20, offset = (100, 100), rotation = math.pi / 3) '
def points(self): e1 = Ellipse(self.width, self.height, self.segments, self.offset, self.rotation, self.pivot) e1_points = e1.points[0] e2 = Ellipse(self.width - (self.inset * 2), self.height - (self.inset * 2), self.segments, self.offset, self.rotation, self.pivot) e2_points = e2.points[0] return [CoordinateArray(e1...
d4 = Donut(100, 50, inset = 5, offset = (100, 100), rotation = math.pi / 3, pivot = (100, 100)) print '\Donut(100, 50, (100, 100), math.pi / 3, (100, 100))'
d4 = Donut(1000, 500, inset = 20, offset = (100, 100), rotation = math.pi / 3, pivot = (100, 100)) print '\Donut(1000, 500, inset = 20, offset = (100, 100), rotation = math.pi / 3, pivot = (100, 100))'
def points(self): e1 = Ellipse(self.width, self.height, self.segments, self.offset, self.rotation, self.pivot) e1_points = e1.points[0] e2 = Ellipse(self.width - (self.inset * 2), self.height - (self.inset * 2), self.segments, self.offset, self.rotation, self.pivot) e2_points = e2.points[0] return [CoordinateArray(e1...
io.view(d1) raw_input() io.view(d2) raw_input() io.view(d3) raw_input() io.view(d4) raw_input()
def points(self): e1 = Ellipse(self.width, self.height, self.segments, self.offset, self.rotation, self.pivot) e1_points = e1.points[0] e2 = Ellipse(self.width - (self.inset * 2), self.height - (self.inset * 2), self.segments, self.offset, self.rotation, self.pivot) e2_points = e2.points[0] return [CoordinateArray(e1...
corners.append(CoordinatePair(point_x, point_y))
corners.append(Coordinate(point_x, point_y))
def points(self): corners = [] pi_div_180 = math.pi / 180.0 half_width = self.width * 0.5 half_height = self.height * 0.5
last_point = CoordinatePair(corners[0])
last_point = Coordinate(corners[0])
def points(self): corners = [] pi_div_180 = math.pi / 180.0 half_width = self.width * 0.5 half_height = self.height * 0.5
def __init__(self, xy, width, height, height_divisions, width_divisions, pen=None):
def __init__(self, xy, width, height, width_divisions, height_divisions, pen=None):
def __init__(self, xy, width, height, height_divisions, width_divisions, pen=None): _CompoundHPGL.__init__(self, xy, pen = pen) self.width = width self.height = height self.height_divisions = height_divisions self.width_divisions = width_divisions self.reference_point = (0, 0) ## range: [0 to 1]
self.width_divisions = width_divisions
def __init__(self, xy, width, height, height_divisions, width_divisions, pen=None): _CompoundHPGL.__init__(self, xy, pen = pen) self.width = width self.height = height self.height_divisions = height_divisions self.width_divisions = width_divisions self.reference_point = (0, 0) ## range: [0 to 1]
x_step_size = self.width / self.width_divisions y_step_size = self.height / self.height_divisions
def _subcommands(self): ul_x = self.xabsolute - self.reference_point[0] * self.width bl_x = ul_x ur_x = ul_x + self.width
for i in range(self.width_divisions + 1): step_y = self.height / self.height_divisions * i
for i in range(self.height_divisions + 1): step_y = y_step_size * i
def _subcommands(self): ul_x = self.xabsolute - self.reference_point[0] * self.width bl_x = ul_x ur_x = ul_x + self.width
for i in range(self.height_divisions + 1): step_x = self.width / self.width_divisions * i
for i in range(self.width_divisions + 1): step_x = x_step_size * i
def _subcommands(self): ul_x = self.xabsolute - self.reference_point[0] * self.width bl_x = ul_x ur_x = ul_x + self.width
self._content = ''
self._content = u''
def __init__(self): """Initialise instance variables.""" self._content = '' self.paths = [] self.msg = '' self.author = '' self.date = '' self.revision = '' self.is_msg = False self.is_author = False self.is_date = False self.is_path = False ContentHandler.__init__(self)
self.msg = '' self.author = '' self.date = '' self.revision = ''
self.msg = u'' self.author = u'' self.date = u'' self.revision = u''
def __init__(self): """Initialise instance variables.""" self._content = '' self.paths = [] self.msg = '' self.author = '' self.date = '' self.revision = '' self.is_msg = False self.is_author = False self.is_date = False self.is_path = False ContentHandler.__init__(self)
self.revision = attrs.get('revision', "")
self.revision = attrs.get('revision', u"")
def startElement(self, name, attrs): """Set flags depending on which Subversion log element is parsed.""" if name == 'logentry': self.revision = attrs.get('revision', "") elif name == 'msg': self.is_msg = True elif name == 'author': self.is_author = True elif name == 'date': self.is_date = True elif name == 'path': sel...
self.paths.append([attrs.get('action', "")])
self.paths.append([attrs.get('action', u""),u''])
def startElement(self, name, attrs): """Set flags depending on which Subversion log element is parsed.""" if name == 'logentry': self.revision = attrs.get('revision', "") elif name == 'msg': self.is_msg = True elif name == 'author': self.is_author = True elif name == 'date': self.is_date = True elif name == 'path': sel...
self.paths[-1].append(content)
self.paths[-1][1] += content
def characters(self, content): """Extract the content of the element.""" if self.is_msg: self.msg += content elif self.is_author: self.author = content elif self.is_date: self.date = content elif self.is_path: self.paths[-1].append(content)
_title = escape("%s: %s" % (self.revision,
_title = escape(u"%s: %s" % (self.revision,
def endElement(self, name): """Reset all the element flags and generate Atom XML if we have reached the end of a logentry.""" if name == 'logentry': self._content += "<entry>" _title = escape("%s: %s" % (self.revision, self.msg.replace('\n', ' '))) self._content += '<title type="text">%s</title>' % _title self._content...
self._content += '<title type="text">%s</title>' % _title self._content += "<id>%s</id>" % self.revision self._content += "<updated>%s</updated>" % self.date self._content += "<author><name>%s</name></author>" % self.author _summary = escape('<p>%s</p><p>Files:<ul>%s</ul></p>' %
self._content += u'<title type="text">%s</title>' % _title self._content += u"<id>%s:%s</id>" % (ATOM_ID, self.revision) self._content += u"<updated>%s</updated>" % self.date self._content += u'<link rel="alternate" href=" self._content += u"<author><name>%s</name></author>" % self.author _summary = escape(u'<p>%s</p><...
def endElement(self, name): """Reset all the element flags and generate Atom XML if we have reached the end of a logentry.""" if name == 'logentry': self._content += "<entry>" _title = escape("%s: %s" % (self.revision, self.msg.replace('\n', ' '))) self._content += '<title type="text">%s</title>' % _title self._content...
''.join(["<li>%s %s</li>" % (a,p) for a,p in self.paths]))) self._content += ('<summary type="html" xml:space="preserve">%s'
''.join([u"<li>%s %s</li>" % (a,p) for a,p in self.paths]))) self._content += (u'<summary type="html" xml:space="preserve">%s'
def endElement(self, name): """Reset all the element flags and generate Atom XML if we have reached the end of a logentry.""" if name == 'logentry': self._content += "<entry>" _title = escape("%s: %s" % (self.revision, self.msg.replace('\n', ' '))) self._content += '<title type="text">%s</title>' % _title self._content...
self._content += "</entry>"
self._content += u"</entry>"
def endElement(self, name): """Reset all the element flags and generate Atom XML if we have reached the end of a logentry.""" if name == 'logentry': self._content += "<entry>" _title = escape("%s: %s" % (self.revision, self.msg.replace('\n', ' '))) self._content += '<title type="text">%s</title>' % _title self._content...
self.msg = ''
self.msg = u''
def endElement(self, name): """Reset all the element flags and generate Atom XML if we have reached the end of a logentry.""" if name == 'logentry': self._content += "<entry>" _title = escape("%s: %s" % (self.revision, self.msg.replace('\n', ' '))) self._content += '<title type="text">%s</title>' % _title self._content...
now = "%sT%s:%s:%sZ" % (now.date(), now.hour, now.minute, now.second) header = """<?xml version="1.0" encoding="utf-8"?>
now = u"%sT%.2d:%.2d:%.2dZ" % (now.date(), now.hour, now.minute, now.second) ATOM_ID = u'tag:svnlogatom.py,2010:%s' % re.sub(r'^.*:/+', '', file_object.url) header = u"""<?xml version="1.0" encoding="utf-8"?>
def generate(file_object, title, link): """Generate the Atom xml.""" now = datetime.utcnow() now = "%sT%s:%s:%sZ" % (now.date(), now.hour, now.minute, now.second) header = """<?xml version="1.0" encoding="utf-8"?>
""" % (title, link, now, __version__)
""" % (title, link, now, ATOM_ID, __version__)
def generate(file_object, title, link): """Generate the Atom xml.""" now = datetime.utcnow() now = "%sT%s:%s:%sZ" % (now.date(), now.hour, now.minute, now.second) header = """<?xml version="1.0" encoding="utf-8"?>
return "%s%s%s" % (header, content, footer)
return u"%s%s%s" % (header, content, footer)
def generate(file_object, title, link): """Generate the Atom xml.""" now = datetime.utcnow() now = "%sT%s:%s:%sZ" % (now.date(), now.hour, now.minute, now.second) header = """<?xml version="1.0" encoding="utf-8"?>
print generate(__file_obj, __title, __link)
print generate(__file_obj, __title, __link).encode('utf8')
def generate(file_object, title, link): """Generate the Atom xml.""" now = datetime.utcnow() now = "%sT%s:%s:%sZ" % (now.date(), now.hour, now.minute, now.second) header = """<?xml version="1.0" encoding="utf-8"?>
manager = self.plotwidget.manager
self.manager = manager = self.plotwidget.manager
def __init__(self, parent, toolbar): QSplitter.__init__(self, parent) self.setContentsMargins(10, 10, 10, 10) self.setOrientation(Qt.Vertical) imagelistwithproperties = ImageListWithProperties(self) self.addWidget(imagelistwithproperties) self.imagelist = imagelistwithproperties.imagelist self.connect(self.imagelist, ...
def lut_range_changed(self, _min, _max):
def lut_range_changed(self):
def lut_range_changed(self, _min, _max): row = self.imagelist.currentRow() self.lut_ranges[row] = _min, _max
self.lut_ranges[row] = _min, _max
self.lut_ranges[row] = self.item.get_lut_range()
def lut_range_changed(self, _min, _max): row = self.imagelist.currentRow() self.lut_ranges[row] = _min, _max
self.item.set_data(data, lut_range) self.connect(plot, SIGNAL('lut_range_changed(double,double)'), self.lut_range_changed)
self.item.set_data(data) if lut_range is None: lut_range = self.item.get_lut_range() contrast_panel = self.manager.get_panel(CONTRAST_PANEL_ID) contrast_panel.set_range(*lut_range)
def show_data(self, data, lut_range=None): plot = self.plotwidget.plot if self.item is not None: self.item.set_data(data, lut_range) self.connect(plot, SIGNAL('lut_range_changed(double,double)'), self.lut_range_changed) else: self.item = make.image(data) plot.add_item(self.item, z=0) plot.replot()
self.curveparam.shade = min([.3, .8/len(items)])
def items_changed(self, plot): self.known_items = {} # Del all cross section items self.del_items(self.get_items(item_type=ICurveItemType)) items = plot.get_items(item_type=ICSImageItemType) if not items: self.replot() return
text = str(textparam.text.replace('\n', '<br>'))
text = textparam.text.replace('\n', '<br>')
def add_label_to_plot(self, filter, event): plot = filter.plot import guidata.dataset as ds class TextParam(ds.datatypes.DataSet): text = ds.dataitems.TextItem("", _("Label")) textparam = TextParam(_("Label text")) if textparam.edit(plot): text = str(textparam.text.replace('\n', '<br>')) from guiqwt.builder import make...
self.menu = QMenu(manager.get_main())
self.menu = QMenu()
def __init__(self, manager): super(DisplayCoordsTool, self).__init__(manager, _("Markers"), icon=get_icon("on_curve.png"), toolbar_id=None) self.menu = QMenu(manager.get_main()) self.canvas_act = manager.create_action(_("Free"), toggled=self.activate_canvas_pointer) self.curve_act = manager.create_action(_("Bound to ac...
self.menu = QMenu(manager.get_main())
self.menu = QMenu()
def __init__(self, manager): super(AspectRatioTool, self).__init__(manager, _("Aspect ratio"), toolbar_id=None) self.ar_param = AspectRatioParam(_("Aspect ratio")) self.menu = QMenu(manager.get_main()) self.lock_action = manager.create_action(_("Lock"), toggled=self.lock_aspect_ratio) self.ratio1_action = manager.creat...
self.menu = QMenu(manager.get_main())
self.menu = QMenu()
def __init__(self, manager): super(AxisScaleTool, self).__init__(manager, _("Scale"), icon=get_icon("log_log.png"), toolbar_id=None) self.menu = QMenu(manager.get_main()) group = QActionGroup(manager.get_main()) lin_lin = manager.create_action("Lin Lin", icon=get_icon("lin_lin.png"), toggled=self.set_scale_lin_lin) lin...
self.menu = QMenu(manager.get_main())
self.menu = QMenu()
def __init__(self, manager): super(ColormapTool, self).__init__(manager, _("Colormap"), tip=_("Select colormap for active " "image")) self.menu = QMenu(manager.get_main()) for cmap_name in get_colormap_list(): cmap = get_cmap(cmap_name) icon = build_icon_from_cmap(cmap) action = self.menu.addAction(icon, cmap_name) act...
LABEL_ANCHOR = "C"
LABEL_ANCHOR = "TL"
def get_position_and_size_text(self): """Return formatted string with position and size of current shape""" tdict = self.get_string_dict() return u"%(center_n)s ( %(center)s )<br>%(size_n)s %(size)s" % tdict
y_offset = self.label.text.size().height()/2+4 self.label.set_position(x, y+y_offset)
self.label.set_position(x, y)
def set_label_position(self): x, y = self.shape.points[0] y_offset = self.label.text.size().height()/2+4 self.label.set_position(x, y+y_offset)
return self._y.size == 0
return self._x is None or self._y is None or self._y.size == 0
def is_empty(self): return self._y.size == 0
if self.source is None or not plot.isVisible():
source = self.get_source_image() if source is None or not plot.isVisible():
def update_item(self, obj): plot = self.plot() if not plot: return if self.source is None or not plot.isVisible(): return sectx, secty = self.get_cross_section(obj) if secty.size == 0 or np.all(np.isnan(secty)): sectx, secty = np.array([]), np.array([]) if self._inverted: self.set_data(secty, sectx) else: self.set_data...
return self.source.get_xsection(obj.yValue(), apply_lut=self.apply_lut)
return source.get_xsection(obj.yValue(), apply_lut=self.apply_lut)
def get_cross_section(self, obj): """Get x-cross section data from source image""" if isinstance(obj, Marker): # obj is a Marker object if self.perimage_mode: return self.source.get_xsection(obj.yValue(), apply_lut=self.apply_lut) else: return get_plot_x_section(obj, apply_lut=self.apply_lut) else: # obj is an Annotate...
return self.source.get_average_xsection(*obj.get_rect(), apply_lut=self.apply_lut)
return source.get_average_xsection(*obj.get_rect(), apply_lut=self.apply_lut)
def get_cross_section(self, obj): """Get x-cross section data from source image""" if isinstance(obj, Marker): # obj is a Marker object if self.perimage_mode: return self.source.get_xsection(obj.yValue(), apply_lut=self.apply_lut) else: return get_plot_x_section(obj, apply_lut=self.apply_lut) else: # obj is an Annotate...
sdiv = self.source.plot().axisScaleDiv(axis_id)
source = self.get_source_image() sdiv = source.plot().axisScaleDiv(axis_id)
def update_scale(self): plot = self.plot() axis_id = plot.xBottom sdiv = self.source.plot().axisScaleDiv(axis_id) plot.setAxisScale(axis_id, sdiv.lowerBound(), sdiv.upperBound()) plot.replot()
return self.source.get_ysection(obj.xValue(), apply_lut=self.apply_lut)
return source.get_ysection(obj.xValue(), apply_lut=self.apply_lut)
def get_cross_section(self, obj): """Get y-cross section data from source image""" if isinstance(obj, Marker): # obj is a Marker object if self.perimage_mode: return self.source.get_ysection(obj.xValue(), apply_lut=self.apply_lut) else: return get_plot_y_section(obj, apply_lut=self.apply_lut) else: # obj is an Annotate...
return self.source.get_average_ysection(*obj.get_rect(), apply_lut=self.apply_lut)
return source.get_average_ysection(*obj.get_rect(), apply_lut=self.apply_lut)
def get_cross_section(self, obj): """Get y-cross section data from source image""" if isinstance(obj, Marker): # obj is a Marker object if self.perimage_mode: return self.source.get_ysection(obj.xValue(), apply_lut=self.apply_lut) else: return get_plot_y_section(obj, apply_lut=self.apply_lut) else: # obj is an Annotate...
sdiv = self.source.plot().axisScaleDiv(axis_id)
source = self.get_source_image() sdiv = source.plot().axisScaleDiv(axis_id)
def update_scale(self): plot = self.plot() axis_id = plot.yLeft sdiv = self.source.plot().axisScaleDiv(axis_id) plot.setAxisScale(axis_id, sdiv.lowerBound(), sdiv.upperBound()) plot.replot()
self.setAxisScale(self.xBottom, x0, x1)
dx = x1-x0 if self.get_axis_direction(self.xBottom): self.setAxisScale(self.xBottom, x0+dx, x0) else: self.setAxisScale(self.xBottom, x0, x0+dx)
def set_plot_limits(self, x0, x1, y0, y1): """Set plot scale limits""" dy = y1-y0 if self.get_axis_direction(self.yLeft): self.setAxisScale(self.yLeft, y0+dy, y0) else: self.setAxisScale(self.yLeft, y0, y0+dy) self.setAxisScale(self.xBottom, x0, x1) self.updateAxes() self.emit(SIG_AXIS_DIRECTION_CHANGED, self, self.yLe...
self.source = src
self.source = weakref.ref(src)
def set_source_image(self, src): """ Set source image (source: object with methods 'get_xsection' and 'get_ysection', e.g. objects derived from guiqwt.image.BaseImageItem) """ self.source = src
if self.source is None or not self.plot().isVisible():
plot = self.plot() if not plot: return if self.source is None or not plot.isVisible():
def update_item(self, obj): if self.source is None or not self.plot().isVisible(): return sectx, secty = self.get_cross_section(obj) if secty.size == 0 or np.all(np.isnan(secty)): sectx, secty = np.array([]), np.array([]) if self._inverted: self.set_data(secty, sectx) else: self.set_data(sectx, secty) if not self.autos...
* x: 1D NumPy array * y: 1D NumPy array
* x: 1D NumPy array, must be increasing * y: 1D NumPy array, must be increasing
def to_bins(x): """Convert point center to point bounds""" bx = np.zeros((x.shape[0]+1,), float) bx[1:-1] = (x[:-1]+x[1:])/2 bx[0] = x[0]-(x[1]-x[0])/2 bx[-1] = x[-1]+(x[-1]-x[-2])/2 return bx
ion()
def main(): ion() x = np.linspace(-5, 5, 1000) figure(1) subplot(2, 1, 1) plot(x, np.sin(x), "r+") plot(x, np.cos(x), "g-") errorbar(x, -1+x**2/20+.2*np.random.rand(len(x)), x/20) xlabel("Axe x") ylabel("Axe y") subplot(2, 1, 2) img = np.fromfunction(lambda x, y: np.sin((x/200.)*(y/200.)**2), (1000, 1000)) xlabel("pixe...
self.set_plot_limits(rect.left(), rect.right(), rect.top(), rect.bottom())
x0, x1 = rect.left(), rect.right() y0, y1 = rect.top(), rect.bottom() if x0 == x1: x0 -= 1 x1 += 1 if y0 == y1: y0 -= 1 y1 += 1 self.set_plot_limits(x0, x1, y0, y1)
def do_autoscale(self, replot=True): """Do autoscale on all axes""" rect = None for item in self.get_items(): if isinstance(item, self.AUTOSCALE_TYPES) and not item.is_empty() \ and item.isVisible(): bounds = item.boundingRect() if rect is None: rect = bounds else: rect = rect.united(bounds) if rect is not None: self.s...
if self.kernel is not None:
if self.has_kernel:
def kill_kernel(self): """ Kill the running kernel. """ if self.kernel is not None: self.kernel.kill() self.kernel = None else: raise RuntimeError("Cannot kill kernel. No kernel is running!")
if self.kernel is not None:
if self.has_kernel:
def signal_kernel(self, signum): """ Sends a signal to the kernel. """ if self.kernel is not None: self.kernel.send_signal(signum) else: raise RuntimeError("Cannot signal kernel. No kernel is running!")
if self.kernel is not None:
if self.has_kernel:
def is_alive(self): """Is the kernel process still running?""" # FIXME: not using a heartbeat means this method is broken for any # remote kernel, it's only capable of handling local kernels. if self.kernel is not None: if self.kernel.poll() is None: return True else: return False else: # We didn't start the kernel wit...
reply = QtGui.QMessageBox.question(self, self.window().windowTitle(), 'Close console?', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: self._frontend.kernel_manager.shutdown_kernel() event.accept() else: event.ignore()
kernel_manager = self._frontend.kernel_manager if kernel_manager and kernel_manager.channels_running: title = self.window().windowTitle() reply = QtGui.QMessageBox.question(self, title, 'Close console?', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: kernel_manager.shutdown_kernel() ev...
def closeEvent(self, event): """ Reimplemented to prompt the user and close the kernel cleanly. """ reply = QtGui.QMessageBox.question(self, self.window().windowTitle(), 'Close console?', QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: self._frontend.kernel_manager.shutdown_kernel() even...
first_reply = QtCore.pyqtSignal(object)
first_reply = QtCore.pyqtSignal()
def stop(self): """ Reimplemented to emit signal. """ super(SocketChannelQObject, self).stop() self.stopped.emit()
return self.in_queue.get(block, timeout)
return self._in_queue.get(block, timeout)
def get_msg(self, block=True, timeout=None): """Get a message if there is one that is ready.""" return self.in_queue.get(block, timeout)
while True:
self._running = True while self._running:
def run(self): """The thread's main activity. Call start() instead.""" self._create_socket()
if xreq[0] != LOCALHOST or sub[0] != LOCALHOST or rep[0] != LOCALHOST or hb[0] != LOCALHOST:
if xreq[0] != LOCALHOST or sub[0] != LOCALHOST or \ rep[0] != LOCALHOST or hb[0] != LOCALHOST:
def start_kernel(self, **kw): """Starts a kernel process and configures the manager to use it.
self.start_kernel(*self._launch_args)
self.start_kernel(**self._launch_args)
def restart_kernel(self): """Restarts a kernel with the same arguments that were used to launch it. If the old kernel was launched with random ports, the same ports will be used for the new kernel. """ if self._launch_args is None: raise RuntimeError("Cannot restart the kernel. " "No previous call to 'start_kernel'.") ...
parser.add_argument('-e', '--existing', action='store_true',
parser.add_argument('-r', '--rich', action='store_true', help='use a rich text frontend') parser.add_argument('-t', '--tab-simple', action='store_true', help='do tab completion ala a Unix terminal') parser.add_argument('--existing', action='store_true',
def main(): """ Entry point for application. """ # Parse command line arguments. parser = ArgumentParser() parser.add_argument('-e', '--existing', action='store_true', help='connect to an existing kernel') parser.add_argument('--ip', type=str, default=LOCALHOST, help='set the kernel\'s IP address [default localhost]') ...
parser.add_argument('--rich', action='store_true', help='use a rich text frontend')
def main(): """ Entry point for application. """ # Parse command line arguments. parser = ArgumentParser() parser.add_argument('-e', '--existing', action='store_true', help='connect to an existing kernel') parser.add_argument('--ip', type=str, default=LOCALHOST, help='set the kernel\'s IP address [default localhost]') ...
super(XReqSocketChannel, self).__init__(context, session, address)
self.ioloop = ioloop.IOLoop()
def __init__(self, context, session, address): self.command_queue = Queue() super(XReqSocketChannel, self).__init__(context, session, address)
self.ioloop = ioloop.IOLoop()
def run(self): """The thread's main activity. Call start() instead.""" self.socket = self.context.socket(zmq.XREQ) self.socket.setsockopt(zmq.IDENTITY, self.session.session) self.socket.connect('tcp://%s:%i' % self.address) self.ioloop = ioloop.IOLoop() self.iostate = POLLERR|POLLIN self.ioloop.add_handler(self.socket...
self.ioloop = ioloop.IOLoop()
def run(self): """The thread's main activity. Call start() instead.""" self.socket = self.context.socket(zmq.SUB) self.socket.setsockopt(zmq.SUBSCRIBE,'') self.socket.setsockopt(zmq.IDENTITY, self.session.session) self.socket.connect('tcp://%s:%i' % self.address) self.ioloop = ioloop.IOLoop() self.iostate = POLLIN|POL...
super(RepSocketChannel, self).__init__(context, session, address)
def __init__(self, context, session, address): self.msg_queue = Queue() super(RepSocketChannel, self).__init__(context, session, address)
xreq, sub = self.xreq_address, self.sub_address if xreq[0] != LOCALHOST or sub[0] != LOCALHOST:
xreq, sub, rep = self.xreq_address, self.sub_address, self.rep_address if xreq[0] != LOCALHOST or sub[0] != LOCALHOST or rep[0] != LOCALHOST:
def start_kernel(self): """Starts a kernel process and configures the manager to use it.
kernel, xrep, pub = launch_kernel(xrep_port=xreq[1], pub_port=sub[1])
kernel, xrep, pub, req = launch_kernel( xrep_port=xreq[1], pub_port=sub[1], req_port=rep[1])
def start_kernel(self): """Starts a kernel process and configures the manager to use it.
self._rep_address = (LOCALHOST, -1)
self._rep_address = (LOCALHOST, req)
def start_kernel(self): """Starts a kernel process and configures the manager to use it.
""" Reimplemented to prompt the user and close the kernel cleanly, or close without prompt only if the exit magic is used.
""" Close the window and the kernel (if necessary). This will prompt the user if they are finished with the kernel, and if so, closes the kernel cleanly. Alternatively, if the exit magic is used, it closes without prompt.
def closeEvent(self, event): """ Reimplemented to prompt the user and close the kernel cleanly, or close without prompt only if the exit magic is used. """ keepkernel = None #Use the prompt by default if hasattr(self._frontend,'_keep_kernel_on_exit'): #set by exit magic keepkernel = self._frontend._keep_kernel_on_exit ...
raise NotImplementedError
self.join() Thread.__init__(self)
def stop(self): """ Stop the thread's activity. Returns when the thread terminates. """ raise NotImplementedError
self.join()
super(SubSocketChannel, self).stop()
def stop(self): self.ioloop.stop() self.join()
self.join()
super(XReqSocketChannel, self).stop()
def stop(self): self.ioloop.stop() self.join()
def stop(self): pass
def stop(self): pass
time_to_dead = 5.0
time_to_dead = 3.0
def _queue_reply(self, msg): self.msg_queue.put(msg) self.add_io_state(POLLOUT)
self.poller.poll(until_dead)
poll_result = self.poller.poll(1000*until_dead)
def run(self): """The thread's main activity. Call start() instead.""" self._create_socket()
self.audiobin.set_state(gst.STATE_PLAYING)
self.pipeline.set_state(gst.STATE_PLAYING)
def startRecordingAudio(self): self.audioPixbuf = None
self.startLiveVideo( False )
self.startLiveVideo()
def resumePlayLiveVideo( self ): self.ca.gplay.stop()
self.startLiveVideo( True )
self.startLiveVideo()
def updateModeChange(self): #this is called when a menubar button is clicked self.LIVEMODE = True self.FULLSCREEN = False self.RECD_INFO_ON = False self.MESHING = False
def startLiveVideo(self, force): if (self.ca.glive.window == self.liveVideoWindow and self.ca.props.active and not force): return self.liveVideoWindow.set_glive(self.ca.glive)
def startLiveVideo(self):
def startLiveVideo(self, force): #We need to know which window and which pipe here
self.startLiveVideo( False )
self.startLiveVideo()
def removeIfSelectedRecorded( self, recd ): if (recd == self.shownRecd): if (recd.type == Constants.TYPE_PHOTO): self.livePhotoCanvas.setImage( None ) elif (recd.type == Constants.TYPE_VIDEO): self.ca.gplay.stop() self.startLiveVideo( False ) elif (recd.type == Constants.TYPE_AUDIO): self.livePhotoCanvas.setImage( None...
self.liveVideoWindow.set_glive(self.ca.glive)
def startLiveAudio( self ): self.ca.m.setUpdating(True) self.ca.gplay.stop()
pad = self.videobin.get_static_pad("sink") pad.set_blocked_async(True, self.blockedCb, None)
self.pipeline.set_state(gst.STATE_NULL)
def startRecordingVideo(self, quality): if not camera_presents: return
self.videobin.set_state(gst.STATE_PLAYING)
def startRecordingVideo(self, quality): if not camera_presents: return
pad.set_blocked_async(False, self.blockedCb, None)
def startRecordingVideo(self, quality): if not camera_presents: return
self.audiobin.set_state(gst.STATE_PLAYING)
self.pipeline.set_state(gst.STATE_PLAYING)
def startRecordingVideo(self, quality): if not camera_presents: return
self.ca.m.saveVideo(self.thumbBuf, str(muxFilepath), self.VIDEO_WIDTH_SMALL, self.VIDEO_HEIGHT_SMALL)
ogg_w = OGG_TRAITS[self.ogg_quality]['width'] ogg_h = OGG_TRAITS[self.ogg_quality]['height'] self.ca.m.saveVideo(self.thumbBuf, str(muxFilepath), ogg_w, ogg_h)
def _onMuxedVideoMessageCb(self, bus, message, pipe): t = message.type if (t == gst.MESSAGE_EOS): self.record = False gobject.source_remove(self.VIDEO_TRANSCODE_ID) self.VIDEO_TRANSCODE_ID = 0 gobject.source_remove(self.TRANSCODE_ID) self.TRANSCODE_ID = 0 pipe.set_state(gst.STATE_NULL) pipe.get_bus().remove_signal_watc...
self.audiobin.set_state(gst.STATE_NULL)
self.pipeline.set_state(gst.STATE_NULL)
def stopRecordingAudio( self ): self.audiobin.set_state(gst.STATE_NULL) self.pipeline.remove(self.audiobin) gobject.idle_add( self.stoppedRecordingAudio )
self.audiobin.add(src, enc, sink) src.link(enc, srccaps) enc.link(sink)
self.audiobin.add(src, queue, enc, sink) src.link(queue, srccaps) gst.element_link_many(queue, enc, sink)
def createAudioBin ( self ): src = gst.element_factory_make("alsasrc", "absrc") srccaps = gst.Caps("audio/x-raw-int,rate=16000,channels=1,depth=16")
queue = gst.element_factory_make("queue", "vbqueue")
def createVideoBin ( self ): queue = gst.element_factory_make("queue", "vbqueue")
self.videobin.add(queue, scale, scalecapsfilter, colorspace, enc, mux, sink) queue.link(scale)
self.videobin.add(scale, scalecapsfilter, colorspace, enc, mux, sink)
def createVideoBin ( self ): queue = gst.element_factory_make("queue", "vbqueue")
pad = queue.get_static_pad("sink")
pad = scale.get_static_pad("sink")
def createVideoBin ( self ): queue = gst.element_factory_make("queue", "vbqueue")
queue = gst.element_factory_make("queue")
queue = gst.element_factory_make("queue", "audioqueue")
def createAudioBin ( self ): src = gst.element_factory_make("alsasrc", "absrc")
queue = gst.element_factory_make("queue")
queue = gst.element_factory_make("queue", "videoqueue") queue.set_property("max-size-time", 5000000000) queue.set_property("max-size-bytes", 33554432) queue.connect("overrun", self.log_queue_overrun)
def createVideoBin ( self ): queue = gst.element_factory_make("queue")
extra_joins = ' '.join(queryset.query.get_from_clause()[0][1:]) where, params = queryset.query.where.as_sql()
if getattr(queryset.query, 'get_compiler', None): compiler = queryset.query.get_compiler(using='default') extra_joins = ' '.join(compiler.get_from_clause()[0][1:]) where, params = queryset.query.where.as_sql( compiler.quote_name_unless_alias, compiler.connection ) else: extra_joins = ' '.join(queryset.query.get_from_...
def usage_for_queryset(self, queryset, counts=False, min_count=None): """ Obtain a list of tags associated with instances of a model contained in the given queryset.
self.animtimestep.setProperty("value", QtCore.QVariant(50))
self.animtimestep.setProperty("value", 50)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(1024, 622) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/logo/logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) MainWindow.setWindowIcon(icon) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName("ce...
import os os.startfile(os.path.dirname(self.lpystudio.simulations[self.selection].fname))
import os, sys mdir = os.path.dirname(self.lpystudio.simulations[self.selection].fname) if sys.platform == 'win32': os.startfile(mdir) elif sys.platform == 'linux2': os.system('xdg-open "'+mdir+'"') else: os.system('open "'+mdir+'"')
def openFolder(self): import os os.startfile(os.path.dirname(self.lpystudio.simulations[self.selection].fname))
if self.isTextEdited() or self.lsystem.empty() :
if self.isTextEdited() or self.lsystem.empty() or self.nbiterations == 0 or self.nbiterations >= self.lsystem.derivationLength:
def pre_animate(self,task): if self.isTextEdited() or self.lsystem.empty() : self.updateLsystemCode() Viewer.start() Viewer.animation(False if self.firstView and task.fitAnimationView else True)
w = self.width() if w == 0: w = 1 h = self.height() if h == 0: h = 1
w,h = self.width(), self.height() if w == 0 or h == 0: return
def paintGL(self): w = self.width() if w == 0: w = 1 h = self.height() if h == 0: h = 1 cursorselection = -1 if self.mousepos != None: cursorselection = self.selectedColor(self.mousepos.x(),self.mousepos.y()) glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0,w,h,0,-3000,1000); glMatrixMode(G...
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) self.renderText(x+px,y+py,0,QString(text))
self.renderText(x+px,y+py,QString(text))
def drawTextIn(self,text,x,y,width, below = False): fm = QFontMetrics(self.font()) tw = fm.width(text) th = fm.height() mtw = width - 3 mth = 20 if below: y += th +1 if mtw < tw: tratio = mtw / float(tw) lt = len(text) nbchar = int(lt * tratio) -3 text = text[0:nbchar/2]+'...'+text[lt-nbchar/2:] tw = fm.width(text) px ...
init_txt += '('+repr(panelinfo)+',['+','.join(['('+repr(manager.typename)+','+manager.getName(obj)+')' for manager,obj in objects])+']),'
init_txt += 'panel_'+str(panelid)+',' panelid += 1
def emptyparameterset(params): for panel,data in params: if len(data) > 0: return False return True