rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
return self.__call_api(values) def __call_api(self, values): """Takes a dictionary of values and talks to the ampache API... returning the root elemnent of the XML"""
def __call(self, **kwargs): """Takes kwargs and talks to the ampach API.. returning the root element of the XML Example: __call(action="artists", filter="kindo") This function automatically adds the 'auth' variable""" values = kwargs values['auth'] = self.auth return self.__call_api(values)
self.side_panel = gtk.VBox()
def __init__(self, ampache_conn, audio_engine, db_session): """Constructor for the AmpacheGUI Class. Takes an AmpacheSession Object, an AudioEngine Object and a DatabaseSession Object.""" ################################# # Set Variables ################################# self.audio_engine = audio_engine self.ampache_co...
self.playlist_list_store = gtk.ListStore(str, str, int)
self.playlist_list_store = gtk.ListStore(gtk.gdk.Pixbuf, str, int)
def __init__(self, ampache_conn, audio_engine, db_session): """Constructor for the AmpacheGUI Class. Takes an AmpacheSession Object, an AudioEngine Object and a DatabaseSession Object.""" ################################# # Set Variables ################################# self.audio_engine = audio_engine self.ampache_co...
new_column = self.__create_column(" ", 0)
new_column = self.__create_column(" ", 0, None, True)
def __init__(self, ampache_conn, audio_engine, db_session): """Constructor for the AmpacheGUI Class. Takes an AmpacheSession Object, an AudioEngine Object and a DatabaseSession Object.""" ################################# # Set Variables ################################# self.audio_engine = audio_engine self.ampache_co...
hpaned.pack1(self.playlist_window)
self.side_panel.pack_start(self.playlist_window) self.downloads_window = gtk.VBox() downloads_panel_scrolled_window = gtk.ScrolledWindow() downloads_panel_scrolled_window.set_shadow_type(gtk.SHADOW_ETCHED_IN) downloads_panel_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) downloads_window_li...
def __init__(self, ampache_conn, audio_engine, db_session): """Constructor for the AmpacheGUI Class. Takes an AmpacheSession Object, an AudioEngine Object and a DatabaseSession Object.""" ################################# # Set Variables ################################# self.audio_engine = audio_engine self.ampache_co...
if view_statusbar == False: self.statusbar.hide()
if show_downloads == False: self.downloads_window.hide() if show_downloads == False and show_playlist == False: self.side_panel.hide()
def __init__(self, ampache_conn, audio_engine, db_session): """Constructor for the AmpacheGUI Class. Takes an AmpacheSession Object, an AudioEngine Object and a DatabaseSession Object.""" ################################# # Set Variables ################################# self.audio_engine = audio_engine self.ampache_co...
now_playing = " "
now_playing = self.images_pixbuf_empty
def __update_playlist_window(self): cur_playlist = self.audio_engine.get_playlist() cur_song_num = self.audio_engine.get_current_song() self.playlist_list_store.clear() i = 0 for temp_song_id in cur_playlist: cur_song = self.ampache_conn.get_playlist_song_dict(temp_song_id) cur_string = cur_song['song_title'] + ' - ' +...
now_playing = ">"
now_playing = self.images_pixbuf_playing
def __update_playlist_window(self): cur_playlist = self.audio_engine.get_playlist() cur_song_num = self.audio_engine.get_current_song() self.playlist_list_store.clear() i = 0 for temp_song_id in cur_playlist: cur_song = self.ampache_conn.get_playlist_song_dict(temp_song_id) cur_string = cur_song['song_title'] + ' - ' +...
def download_song(self, url, dst, progress_bar=None): print "get url '%s' to '%s'" % (url, dst) if sys.stdout.isatty(): urllib.urlretrieve(url, dst, lambda nb, bs, fs, url=url: self._reporthook(nb,bs,fs,url,progress_bar)) else: urllib.urlretrieve(url, dst) def _reporthook(self, numblocks, blocksize, filesize, url, pr...
def __update_playlist_window(self): cur_playlist = self.audio_engine.get_playlist() cur_song_num = self.audio_engine.get_current_song() self.playlist_list_store.clear() i = 0 for temp_song_id in cur_playlist: cur_song = self.ampache_conn.get_playlist_song_dict(temp_song_id) cur_string = cur_song['song_title'] + ' - ' +...
def __create_column(self, column_name, column_id, sort_column=None):
def __create_column(self, column_name, column_id, sort_column=None, pixbuf=False):
def __create_column(self, column_name, column_id, sort_column=None): """Helper function for treeviews, this will return a column ready to be appended.""" renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn(column_name, renderer_text, text=column_id) if sort_column != None: column.set_sort_column_id(sort_...
renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn(column_name, renderer_text, text=column_id)
if pixbuf: renderer_text = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn(column_name) column.pack_start(renderer_text, expand=False) column.add_attribute(renderer_text, 'pixbuf', 0) else: renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn(column_name, renderer_text, text=column_id)
def __create_column(self, column_name, column_id, sort_column=None): """Helper function for treeviews, this will return a column ready to be appended.""" renderer_text = gtk.CellRendererText() column = gtk.TreeViewColumn(column_name, renderer_text, text=column_id) if sort_column != None: column.set_sort_column_id(sort_...
self.disconnect(self._padd_hid) self.disconnect(self._prem_hid)
def _remove_functions(self): self._setup_done = False for name in self._proxy_names: delattr(self, name) self._proxy_names = [] self._ins = None
self._hup_hid = gobject.io_add_watch(self.socket, \
self._hup_hid = None
def __init__(self, sock, client_address, server, packet_len=False): ''' If packet_len is True, the first 2 bytes received are expected to contain the packet length. The receive function will block until the whole packet is ready. '''
self._instrument.set(self._parameter, val)
self._instrument.set(self._parameter, val, callback=lambda *x: True)
def do_set(self): self._dirty = False val = self.get_text() self._instrument.set(self._parameter, val)
self._instrument.set(self._parameter, val)
self._instrument.set(self._parameter, val, callback=lambda *x: True)
def do_set(self): val = self.get_value() self._instrument.set(self._parameter, val)
if type(self._map) is types.DictType:
if type(self._map) is types.DictType and val in self._map:
def _update_value(self, val): if val is None: return
hbox1 = gtk.HBox(spacing=10) hbox1.pack_start(gtk.Label(_L('Name')), False, False) hbox1.pack_start(self._plot_name, False, True) hbox2 = gtk.HBox(spacing=10) hbox2.pack_start(gtk.Label(_L('Clear')), False, False) hbox2.pack_start(self._clear_check, False, True) hbox3 = gtk.HBox(spacing=10) hbox3.pack_start(gtk.Label(_...
self._ofs_entry = gtk.Entry() self._traceofs_entry = gtk.Entry() vbox1 = gui.pack_vbox([ gui.pack_hbox([ gtk.Label(_L('Name')), self._plot_name], False, False), gui.pack_hbox([ gtk.Label(_L('Clear')), self._clear_check], False, False), gui.pack_hbox([ gtk.Label(_L('Style')), self._plot_style], False, False), gui.pack_...
def __init__(self): qtwindow.QTWindow.__init__(self, 'data', _L('Data Browser')) self.connect("delete-event", self._delete_event_cb)
hbox1, hbox2, hbox3, hbox4,
gui.pack_hbox([vbox1, vbox2], True, True),
def __init__(self): qtwindow.QTWindow.__init__(self, 'data', _L('Data Browser')) self.connect("delete-event", self._delete_event_cb)
d = qt.Data(fullfn) qt.plot(d, style, name=name, coorddim=coorddim, valdim=valdim, clear=clear)
cmd = "qt.plot(qt.Data(%r), name=%r, style=%r, coorddim=%r, valdim=%r, ofs=%r, traceofs=%r, clear=%r, ret=False)" % (fullfn, name, style, coorddim, valdim, ofs, traceofs, clear); qt.interpreter.cmd(cmd, callback=lambda x: self._plot2d_button.set_sensitive(True))
def _plot2d_clicked_cb(self, sender): name = self._plot_name.get_text() style = self._plot_style.get_text() clear = self._clear_check.get_active() files = self._get_selected_files() cols = self._columns.get_text().split(',') try: coorddim = int(cols[0]) valdim = int(cols[1]) except: if cols != [""]: logging.warning('in...
d = qt.Data(self._entry_map[fn].get_filename()) qt.plot3(d, name=name, coorddims=coorddims, valdim=valdim, clear=clear)
fullfn = self._entry_map[fn].get_filename() cmd = "qt.plot3(qt.Data(%r), name=%r, style=%r, coorddim=%r, valdim=%r, ofs=%r, traceofs=%r, clear=%r, ret=False)" % (fullfn, name, style, coorddims, valdim, ofs, traceofs, clear); qt.interpreter.cmd(cmd, callback=lambda x: self._plot3d_button.set_sensitive(True))
def _plot3d_clicked_cb(self, sender): name = self._plot_name.get_text() clear = self._clear_check.get_active() files = self._get_selected_files() cols = self._columns.get_text().split(',') try: coorddims = (int(cols[0]), int(cols[1])) valdim = int(cols[2]) except: if cols != [""]: logging.warning('invalid column specif...
dict(x='((1-gray)**gamma)')
dict(x='(1-gray**gamma)')
def _palette_func(self, func_id): if func_id >= 0: return self._PALETTE_FUNCTIONS[abs(func_id)] % \ dict(x='(gray**gamma)') else: return self._PALETTE_FUNCTIONS[abs(func_id)] % \ dict(x='((1-gray)**gamma)')
self.add_parameter('trigger_continuous', flags=Instrument.FLAG_GETSET, type=types.BooleanType)
def __init__(self, name, address, reset=False, change_display=True, change_autozero=True): ''' Initializes the Keithley_2100, and communicates with the wrapper.
units='s', minval=0, maxval=999999.999, type=types.FloatType)
units='s', minval=-1, maxval=999999.999, type=types.FloatType)
def __init__(self, name, address, reset=False, change_display=True, change_autozero=True): ''' Initializes the Keithley_2100, and communicates with the wrapper.
self.add_parameter('trigger_timer', flags=Instrument.FLAG_GETSET, units='s', minval=0.001, maxval=99999.999, type=types.FloatType)
def __init__(self, name, address, reset=False, change_display=True, change_autozero=True): ''' Initializes the Keithley_2100, and communicates with the wrapper.
units='AU', type=types.FloatType, tags=['measure']) self.add_parameter('readlastval', flags=Instrument.FLAG_GET, units='AU', type=types.FloatType, tags=['measure']) self.add_parameter('readnextval', flags=Instrument.FLAG_GET,
def __init__(self, name, address, reset=False, change_display=True, change_autozero=True): ''' Initializes the Keithley_2100, and communicates with the wrapper.
self.add_function('set_trigger_cont') self.add_function('set_trigger_disc')
def __init__(self, name, address, reset=False, change_display=True, change_autozero=True): ''' Initializes the Keithley_2100, and communicates with the wrapper.
self.add_function('readlast')
def __init__(self, name, address, reset=False, change_display=True, change_autozero=True): ''' Initializes the Keithley_2100, and communicates with the wrapper.
if reset: self.reset() else: self.get_all()
self.reset() self.get_all() if not reset:
def __init__(self, name, address, reset=False, change_display=True, change_autozero=True): ''' Initializes the Keithley_2100, and communicates with the wrapper.
Trigger=Continous
def set_defaults(self): ''' Set to driver defaults: Output=data only Mode=Volt:DC Digits=7 Trigger=Continous Range=10 V NPLC=1 Averaging=off '''
self.set_trigger_continuous(True)
def set_defaults(self): ''' Set to driver defaults: Output=data only Mode=Volt:DC Digits=7 Trigger=Continous Range=10 V NPLC=1 Averaging=off '''
self.get_trigger_continuous()
def get_all(self): ''' Reads all relevant parameters from instrument
def readlast(self): ''' Old function for read-out, links to get_readlastval() ''' logging.debug('Link to get_readlastval()') return self.get_readlastval() def readnext(self): ''' Links to get_readnextval ''' logging.debug('Link to get_readnextval()') return self.get_readnextval()
def readlast(self): ''' Old function for read-out, links to get_readlastval() ''' logging.debug('Link to get_readlastval()') return self.get_readlastval()
trigger_status = self.get_trigger_continuous(query=False) if (trigger_status): logging.warning('Trigger is set to continous, sending trigger impossible') elif (not trigger_status): logging.debug('Sending trigger') self._visainstrument.write('INIT') self._trigger_sent = True else: logging.error('Error in retrieving trig...
logging.debug('Sending trigger') self._visainstrument.write('INIT') self._trigger_sent = True
def send_trigger(self): ''' Send trigger to Keithley, use when triggering is not continous. ''' trigger_status = self.get_trigger_continuous(query=False) if (trigger_status): logging.warning('Trigger is set to continous, sending trigger impossible') elif (not trigger_status): logging.debug('Sending trigger') self._visa...
Get data at this instance, not recommended, use get_readlastval.
Get data at this instance, not recommended, use get_readval.
def fetch(self): ''' Get data at this instance, not recommended, use get_readlastval. Use send_trigger() to trigger the device. Note that Readval is not updated since this triggers itself. '''
trigger_status = self.get_trigger_continuous(query=False) if self._trigger_sent and (not trigger_status):
if self._trigger_sent:
def fetch(self): ''' Get data at this instance, not recommended, use get_readlastval. Use send_trigger() to trigger the device. Note that Readval is not updated since this triggers itself. '''
elif (not self._trigger_sent) and (not trigger_status):
else:
def fetch(self): ''' Get data at this instance, not recommended, use get_readlastval. Use send_trigger() to trigger the device. Note that Readval is not updated since this triggers itself. '''
else: logging.error('Triggering is on continous!')
def fetch(self): ''' Get data at this instance, not recommended, use get_readlastval. Use send_trigger() to trigger the device. Note that Readval is not updated since this triggers itself. '''
def set_trigger_cont(self): ''' Set trigger mode to continuous, old function, uses set_Trigger_continuous(True). Input: None Output: None ''' logging.debug('Set Trigger to continuous mode') self.set_trigger_continuous(True) def set_trigger_disc(self): ''' Set trigger mode to Discrete Input: None Output: None ''' l...
def set_range_auto(self, mode=None): ''' Old function to set autorange, links to set_autorange() ''' logging.debug('Redirect to set_autorange') self.set_autorange(True)
def do_get_readnextval(self):
def do_get_readval(self):
def do_get_readnextval(self): ''' Waits for the next value available and returns it as a float. Note that if the reading is triggered manually, a trigger must be send first to avoid a time-out.
trigger_status = self.get_trigger_continuous(query=False) if (not trigger_status) and (not self._trigger_sent): logging.error('No trigger has been send, return 0') return float(0) self._trigger_sent = False
def do_get_readnextval(self): ''' Waits for the next value available and returns it as a float. Note that if the reading is triggered manually, a trigger must be send first to avoid a time-out.
def do_get_readlastval(self): ''' Returns the last measured value available and returns it as a float. Note that if this command is send twice in one integration time it will return the same value. Example: If continually triggering at 1 PLC, don't use the command within 1 PLC again, but wait 20 ms. If you want the Ke...
def do_get_readnextval(self): ''' Waits for the next value available and returns it as a float. Note that if the reading is triggered manually, a trigger must be send first to avoid a time-out.
def do_set_trigger_continuous(self, val): ''' Set trigger mode to continuous. Input: val (boolean) : Trigger on or off Output: None ''' val = bool_to_str(val) logging.debug('Set trigger mode to %s' % val) self._set_func_par_value('TRIG', 'DEL:AUTO', bool_to_str(val)) def do_get_trigger_continuous(self): ''' Get trig...
def do_get_nplc(self, mode=None, unit='APER'): ''' Get integration time in Number of PowerLine Cycles. To get the integrationtime in seconds, use get_integrationtime(). If mode=None the current mode is assumed
val (float) : Trigger delay in seconds Output: None ''' logging.debug('Set trigger delay to %s' % val) self._set_func_par_value('TRIG', 'DEL', val)
val (float) : Trigger delay in seconds or -1 for auto Output: None ''' if val == -1: logging.debug('Set trigger delay to auto') self._set_func_par_value('TRIG', 'DEL:AUTO', 'OFF') else: logging.debug('Set trigger delay to %s sec', val) self._set_func_par_value('TRIG', 'DEL', '%s' % val)
def do_set_trigger_delay(self, val): ''' Set trigger delay to the specified value
delay (float) : Delay in seconds ''' logging.debug('Get trigger delay') return float(self._get_func_par('TRIG', 'DEL'))
delay (float) : Delay in seconds, or -1 for auto ''' logging.debug('Read trigger delay from instrument') val = self._get_func_par('TRIG', 'DEL:AUTO') if val == '1': return -1 else: return self._get_func_par('TRIG', 'DEL')
def do_get_trigger_delay(self): ''' Read trigger delay from instrument
self.set_parameter_options('readlastval', units=unit) self.set_parameter_options('readnextval', units=unit)
def _change_units(self, unit): self.set_parameter_options('readval', units=unit) self.set_parameter_options('readlastval', units=unit) self.set_parameter_options('readnextval', units=unit)
self._filepath = os.path.join(self._config['qtlabdir'],
self._filepath = os.path.join(self._config['execdir'],
def __init__(self, name, address, reset=False, numdacs=8): ''' Initializes the SMS, and communicates with the wrapper Dacvalues are stored in "'SMS_' + address + '.dat'" ??really??
if request.POST.get("role", '') == 'admin': user.is_superuser = True user.is_staff = True elif request.POST.get("role", '') == 'staff': user.is_staff = True user.save() vars = { 'user_name' : user.get_full_name(), 'administrator': user.is_superuser } template = 'books/update_staff/saved.html' return rtr(template, vars,...
def update_staff(request): if request.method == 'POST': student_id = request.POST.get("student_id", '') action = request.POST.get('Action') else: return HttpResponseNotAllowed(['POST']) # Delete User if action == "Delete" and student_id: # Delete single try: user = User.objects.get(id = student_id) user.is_superuser = ...
twupass_backend = TWUPassBackend() user = twupass_backend.import_user(student_id) if user: template = 'books/update_staff/saved.html' return rtr(template, vars, context_instance=RC(request)) else: return tidy_error(request, "Invalid Student ID: %s" % student_id)
twupass_backend = TWUPassBackend() user = twupass_backend.import_user(student_id) if user == None: return tidy_error(request, "Invalid Student ID: %s" % student_id) if request.POST.get("role", '') == 'admin': user.is_superuser = True user.is_staff = True elif request.POST.get("role", '') == 'staff': user.is_staff = Tru...
def update_staff(request): if request.method == 'POST': student_id = request.POST.get("student_id", '') action = request.POST.get('Action') else: return HttpResponseNotAllowed(['POST']) # Delete User if action == "Delete" and student_id: # Delete single try: user = User.objects.get(id = student_id) user.is_superuser = ...
if bunch.count() > 30:
if bunch.count() > 30 and action[:4] == "Place on Hold"[:4]:
def update_book(request): """ This view is used to update book data """ bunch = Book.objects.none() action = request.POST.get("Action", '') for key, value in request.POST.items(): if "idToEdit" in key: bunch = bunch | Book.objects.filter(pk=int(value)) # a hacky fix that stops people from placing all the books in the ...
class SeachBookTest(TestCase):
class SearchBookTest(TestCase):
#def test_add(self):
sold_books = Book.objects.filter(status='S', sell_date__gte=from_date).exclude(sell_date__gt=to_date)
book_sale_logs = Log.objects.filter(action='S', when__gte=from_date).exclude(when__gt=to_date)
def books_sold_within_date(request): """ Shows a list of all books sold within a given date range """ if request.method != "POST": return HttpResponseNotAllowed(['GET']) date_range_form = DateRangeForm(request.POST) if not date_range_form.is_valid(): vars = { 'date_range_form' : date_range_form, } return rtr('books/rep...
'sold_books' : sold_books.order_by('sell_date'),
'book_sale_logs' : book_sale_logs.order_by('book__sell_date'),
def books_sold_within_date(request): """ Shows a list of all books sold within a given date range """ if request.method != "POST": return HttpResponseNotAllowed(['GET']) date_range_form = DateRangeForm(request.POST) if not date_range_form.is_valid(): vars = { 'date_range_form' : date_range_form, } return rtr('books/rep...
'book_id' : book.id
'book_id' : book.id, 'edition' : '1',
def update_book_edit(request): """ Applies changes to a book made on the edit page If the barcode doesn't exist, it makes the user create a MetaBook object as well """ if request.method == "POST": form = BookForm(request.POST) if form.is_valid(): id = request.POST.get('IdToEdit') try: book = Book.objects.get(id=id) exc...
'price' : price
'price' : price, 'edition' : '1',
def add_book(request): if request.method == "POST": form = BookForm(request.POST) if form.is_valid(): student_id = form.cleaned_data['seller'] price = form.cleaned_data['price'] barcode = form.cleaned_data['barcode'] try: metabook = MetaBook.objects.get(barcode=barcode) except MetaBook.DoesNotExist: initial = { 'barcod...
fixtures = ['test_3_for_sale.json']
fixtures = ['test_empty.json'] TITLE = 'The Silmarillion' AUTHOR = 'J.R.R. Tolkien' BARCODE = '9780618391110' EDITION = 1
def test_feedback(self): """ Make sure feedback is correct when adding a new book """ author = 'Bruce Wilkinson' title = 'The Prayer of Jabez' book_id = '1' post_data = { 'barcode' : '9781590524756', 'seller' : '3', 'price' : '4.78', 'author' : author, 'title' : title, 'edition' : '1', 'department' : 'RELS', 'course_nu...
self.get_data['filter'] = '9780618391110'
self.get_data['filter'] = self.BARCODE
def test_barcode(self): """ Searching for barcodes in book list should work """ self.get_data['field'] = 'barcode' self.get_data['filter'] = '9780618391110' response = self.client.get('/books/', self.get_data) self.assertContains(response, 'The Silmarillion')
self.assertContains(response, 'The Silmarillion') def test_barcode_any_field(self): """ Searching for barcodes in in 'any_field" in the book list should work """
self.assertContains(response, self.TITLE) def test_barcode_anyfield(self): """ Searching for barcodes in any field """
def test_barcode(self): """ Searching for barcodes in book list should work """ self.get_data['field'] = 'barcode' self.get_data['filter'] = '9780618391110' response = self.client.get('/books/', self.get_data) self.assertContains(response, 'The Silmarillion')
vars = { 'form' : form, 'attach' : True, } template = 'books/add_listing_and_book.html'
vars = {'form' : form} template = 'books/attach_book.html'
def update_listing_edit(request): """ Applies changes to a listing made on the edit page If the barcode doesn't exist, it makes the user create a Book object as well """ if request.method == "POST": form = ListingForm(request.POST) if form.is_valid(): id = request.POST.get('IdToEdit') try: listing = Listing.objects.get...
vars = { 'form' : form, 'attach' : True, } template = 'books/add_listing_and_book.html'
vars = {'form' : form} template = 'books/attach_book.html'
def attach_book(request): if request.method == 'POST': form = BookAndListingForm(request.POST) if form.is_valid(): # shorten our code line lengths below goc = Course.objects.get_or_create cd = form.cleaned_data # Get the course if it exists, otherwise create it. tpl = goc(department=cd['department'], number=cd['course...
vars = { 'form' : form, 'attach' : False, }
vars = {'form' : form}
def add_listing(request): if request.method == "POST": form = ListingForm(request.POST) if form.is_valid(): student_id = form.cleaned_data['seller'] price = form.cleaned_data['price'] barcode = form.cleaned_data['barcode'] try: book = Book.objects.get(barcode=barcode) except Book.DoesNotExist: initial = { 'barcode' : b...
g = lambda x: request.POST.get(x, '') barcode, price, sid, author, title, ed, dept, course_num =\ g('barcode'), g('price'), int(g('seller')), g('author'),\ g('title'), g('edition'), g('department'), g('course_number') book = Book(barcode=barcode, author=author, title=title, edition=ed) book.save() goc = Course.objects....
form = BookAndListingForm(request.POST) if form.is_valid(): g = lambda x: request.POST.get(x, '') barcode, price, sid, author, title, ed, dept, course_num =\ g('barcode'), g('price'), int(g('seller')), g('author'),\ g('title'), g('edition'), g('department'), g('course_number') book = Book(barcode=barcode, author=auth...
def add_listing_and_book(request): if request.method == "POST": if request.POST.get("Action", '') == 'Add': # This came from the add_book view, and we need to # create a book and a listing g = lambda x: request.POST.get(x, '') barcode, price, sid, author, title, ed, dept, course_num =\ g('barcode'), g('price'), int(g('...
return author(filter).distinct() |\
return title(filter).distinct() |\
def author(filter): return listings.filter(book__author__icontains=filter)
if is_old_xbmc(): folders.append(('Old XBMC Warning', 'old_xbmc', make_url(tvradio='old_xbmc')))
def list_tvradio(): """ Lists five folders - one for TV and one for Radio, plus A-Z, highlights and popular """ xbmcplugin.addSortMethod(handle=PLUGIN_HANDLE, sortMethod=xbmcplugin.SORT_METHOD_TRACKNUM) folders = [] folders.append(('TV', 'tv', make_url(tvradio='tv'))) folders.append(('Radio', 'radio', make_url(tvradio...
listitem.setThumbnailImage(get_plugin_thumbnail(tn))
thumbnail = get_plugin_thumbnail(tn) if thumbnail: listitem.setThumbnailImage(get_plugin_thumbnail(tn))
def list_tvradio(): """ Lists five folders - one for TV and one for Radio, plus A-Z, highlights and popular """ xbmcplugin.addSortMethod(handle=PLUGIN_HANDLE, sortMethod=xbmcplugin.SORT_METHOD_TRACKNUM) folders = [] folders.append(('TV', 'tv', make_url(tvradio='tv'))) folders.append(('Radio', 'radio', make_url(tvradio...
if label == 'Settings':
if label == 'Settings' or label == 'Old XBMC Warning':
def list_tvradio(): """ Lists five folders - one for TV and one for Radio, plus A-Z, highlights and popular """ xbmcplugin.addSortMethod(handle=PLUGIN_HANDLE, sortMethod=xbmcplugin.SORT_METHOD_TRACKNUM) folders = [] folders.append(('TV', 'tv', make_url(tvradio='tv'))) folders.append(('Radio', 'radio', make_url(tvradio...
pDialog.update(0) times.append(['pDialog.update(0)',time.clock()])
def watch(feed, pid, showDialog): times = [] times.append(['start',time.clock()]) if showDialog: pDialog = xbmcgui.DialogProgress() times.append(['xbmcgui.DialogProgress()',time.clock()]) pDialog.update(0) times.append(['pDialog.update(0)',time.clock()]) pDialog.create('IPlayer', 'Loading catchup stream info') times.a...
xbmc.sleep(50) times.append(['xbmc.sleep(50)',time.clock()])
def watch(feed, pid, showDialog): times = [] times.append(['start',time.clock()]) if showDialog: pDialog = xbmcgui.DialogProgress() times.append(['xbmcgui.DialogProgress()',time.clock()]) pDialog.update(0) times.append(['pDialog.update(0)',time.clock()]) pDialog.create('IPlayer', 'Loading catchup stream info') times.a...
print pref
def watch(feed, pid, showDialog): times = [] times.append(['start',time.clock()]) if showDialog: pDialog = xbmcgui.DialogProgress() times.append(['xbmcgui.DialogProgress()',time.clock()]) pDialog.update(0) times.append(['pDialog.update(0)',time.clock()]) pDialog.create('IPlayer', 'Loading catchup stream info') times.a...
d.ok('Welcome to BBC IPlayer plugin.', 'Please be aware this plugin only works in the UK.', 'The IPlayer service checks to ensure UK IP addresses.') d.ok('Note about streams', 'This plugin will only work on XBMC versions that', 'include libRTMP support. See the plugin website', 'for more information.' )
d.ok('Welcome to BBC IPlayer plugin', 'Please be aware this plugin only works in the UK.', 'The IPlayer service checks to ensure UK IP addresses.') if is_old_xbmc(): show_version_warning()
def listen_live(label='', url=None): if not url: return txt = iplayer.httpget(url) # some of the the urls passed in are .asx. These are text files with multiple mss stream hrefs stream = re.compile('href\="(mms.*?)"', re.IGNORECASE) match = stream.search(txt) stream_url = None if match: stream_url = match.group(1) ...
return ( addoncompat.get_os() == "xbox" and xbmc_rev < 30366 ) or xbmc_rev < 31519
return ( addoncompat.get_os() != "xbox" and xbmc_rev < 31519) or xbmc_rev < 30366
def is_old_xbmc(): xbmc_rev = addoncompat.get_revision() return ( addoncompat.get_os() == "xbox" and xbmc_rev < 30366 ) or xbmc_rev < 31519
fh = open(filename, "w")
fh = open(filename, "wb")
def file_write(filename, data): fh = open(filename, "w") try: fh.write(data) finally: fh.close()
if os.path.isfile(VERSION_FILE): old_version = file_read(VERSION_FILE) if old_version != __version__: file_write(VERSION_FILE, __version__) d = xbmcgui.Dialog() d.ok('Welcome to BBC IPlayer plugin', 'Please be aware this plugin only works in the UK.', 'The IPlayer service checks to ensure UK IP addresses.') if is_old...
DIR_USERDATA for d in [DIR_USERDATA, HTTP_CACHE_DIR, SUBTITLES_DIR]:
def listen_live(label='', url=None): if not url: return txt = iplayer.httpget(url) # some of the the urls passed in are .asx. These are text files with multiple mss stream hrefs stream = re.compile('href\="(mms.*?)"', re.IGNORECASE) match = stream.search(txt) stream_url = None if match: stream_url = match.group(1) ...
raise
raise if os.path.isfile(VERSION_FILE): old_version = file_read(VERSION_FILE) if old_version != __version__: file_write(VERSION_FILE, __version__) d = xbmcgui.Dialog() d.ok('Welcome to BBC IPlayer plugin', 'Please be aware this plugin only works in the UK.', 'The IPlayer service checks to ensure UK IP addresses.') if...
def listen_live(label='', url=None): if not url: return txt = iplayer.httpget(url) # some of the the urls passed in are .asx. These are text files with multiple mss stream hrefs stream = re.compile('href\="(mms.*?)"', re.IGNORECASE) match = stream.search(txt) stream_url = None if match: stream_url = match.group(1) ...
a = findanimal(row[ADOPTIONNO].strip()) if a != None: a.RabiesTag = row[TAG].strip()
def ftadd(s): return ft(s.replace("\n", ", "))
o.OwnerAddress = ft(row[ADDRESS])
o.OwnerAddress = ftadd(row[ADDRESS])
def ft(s): return s.strip().title().replace("\\", "")
asm.setid("animal", 1000) asm.setid("adoption", 1000)
def tocurrency(s): if s.strip() == "": return 0.0 s = s.replace("$", "") try: return float(s) except: return 0.0
print "Present slot:", args
def slot_info( self, path, args, types ): self.dnosc.info_slot( args[0], args[1], args[2], args[3] ) print "Present slot:", args
print "Node data:", args
def node_data( self, path, args, types ): self.dnosc.data_for_node( args[0], args[1:] ) print "Node data:", args
print "Slot string data:", args
def slot_datas( self, path, args, types ): self.dnosc.data_for_slot( args[0], args[1], args[2] ) print "Slot string data:", args
print "Slot numerical data:", args
def slot_dataf( self, path, args, types ): self.dnosc.data_for_slot( args[0], args[1], args[2] ) print "Slot numerical data:", args
network.setNodeData( nodeid, data )
self.network.setNodeData( nodeid, data )
def data_for_node( self, nodeid, data ): network.setNodeData( nodeid, data )
network.setSlotData( nodeid, slotid, data )
self.network.setSlotData( nodeid, slotid, data )
def data_for_slot( self, nodeid, slotid, data ): network.setSlotData( nodeid, slotid, data )
network.addExpectedNode( nodeid )
self.network.addExpectedNode( nodeid )
def expected_node( self, nodeid ): network.addExpectedNode( nodeid )
network.infoNode( nodeid, label, size, dntype )
print "info_node", nodeid, label, size, dntype self.network.infoNode( nodeid, label, size, dntype )
def info_node( self, nodeid, label, size, dntype ): network.infoNode( nodeid, label, size, dntype )
network.infoSlot( nodeid, slotid, label, dntype )
self.network.infoSlot( nodeid, slotid, label, dntype )
def info_slot( self, nodeid, slotid, label, dntype ): network.infoSlot( nodeid, slotid, label, dntype )
def register( self ):
def register( self, mycallback = None ):
def register( self ): self.sendSimpleMessage( "/register" ) #msg = liblo.Message( "/register", self.port, self.name ) #self.sendMessage( msg ) #del msg
def unregister( self ):
if mycallback != None: self.callbacks[ 'register' ] = mycallback def unregister( self, mycallback = None ): if mycallback != None: self.callbacks[ 'unregister' ] = mycallback
def register( self ): self.sendSimpleMessage( "/register" ) #msg = liblo.Message( "/register", self.port, self.name ) #self.sendMessage( msg ) #del msg
def subscribeNode( self, nodeid ):
def subscribeNode( self, nodeid, mycallback = None ): if mycallback != None: if 'subscribe' not in self.callbacks: self.callbacks[ 'subscribe' ] = {} self.callbacks[ 'subscribe' ][ nodeid ] = mycallback
def subscribeNode( self, nodeid ): msg = liblo.Message( "/subscribe/node", self.port, self.name, nodeid ) self.sendMessage( msg ) del msg
def __init__(self, network, nid, size, label, dtype ):
def __init__(self, network, nid, insize, label, dtype ):
def __init__(self, network, nid, size, label, dtype ): self.network = network self.nodeid = nid self.size = size self.label = label self.dtype = dtype self.data = [] self.slotlabels = []
self.size = size
self.size = insize
def __init__(self, network, nid, size, label, dtype ): self.network = network self.nodeid = nid self.size = size self.label = label self.dtype = dtype self.data = [] self.slotlabels = []
self.data = [] self.slotlabels = []
self.action = None self.data = list( 0 for i in range( 1, insize+1 ) ) self.slotlabels = list( "slot_{0!s}_{1!s}".format( nid, i ) for i in range(1,insize+1) ) def setAction( self, action ): self.action = action
def __init__(self, network, nid, size, label, dtype ): self.network = network self.nodeid = nid self.size = size self.label = label self.dtype = dtype self.data = [] self.slotlabels = []
if slotid < size:
if slotid < self.size:
def setLabelSlot( self, slotid, label ): if slotid < size: self.slotlabels[slotid] = label
if slotid < size:
if slotid < self.size:
def setDataSlot( self, slotid, data ): if slotid < size: self.data[slotid] = data
if self.action != None: self.action( self.data )
def setData( self, data ): if len( data ) == self.size : self.data = data
self.expectednodes.add( nodeid )
self.expectednodes.append( nodeid )
def addExpectedNode( self, nodeid ): self.expectednodes.add( nodeid ) print "Expected nodes:", self.expectednodes
try:
if nodeid not in self.nodes: self.nodes[ nodeid ] = DataNode( self, nodeid, size, label, dntype ) else:
def infoNode( self, nodeid, label, size, dntype ): try: self.nodes[ nodeid ].setLabel( label ) self.nodes[ nodeid ].setSize( size ) self.nodes[ nodeid ].setType( dntype ) except: print "InfoNode: nodeid ", nodeid, "not in nodes", self.nodes
except:
if nodeid not in self.nodes:
def infoNode( self, nodeid, label, size, dntype ): try: self.nodes[ nodeid ].setLabel( label ) self.nodes[ nodeid ].setSize( size ) self.nodes[ nodeid ].setType( dntype ) except: print "InfoNode: nodeid ", nodeid, "not in nodes", self.nodes
try:
if nodeid in self.nodes:
def infoSlot( self, nodeid, slotid, label, dntype ): try: self.nodes[ nodeid ].setLabelSlot( slotid, label ) except: print "InfoSlot: nodeid ", nodeid, "not in nodes", self.nodes
except:
else:
def infoSlot( self, nodeid, slotid, label, dntype ): try: self.nodes[ nodeid ].setLabelSlot( slotid, label ) except: print "InfoSlot: nodeid ", nodeid, "not in nodes", self.nodes
try:
if nodeid in self.nodes:
def setNodeData( self, nodeid, data ): try: self.nodes[ nodeid ].setData( data ) except: print "DataNode: nodeid ", nodeid, "not in nodes", self.nodes