bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def clickedLabelButton(self): button = self.get_checked_label_button() label_name = str(button.text()) if label_name != self.last_checked_label: print label_name, self.last_checked_label self.last_checked_label = label_name self.update_buttons()
def clickedLabelButton(self): button = self.get_checked_label_button() label_name = str(button.text()) if label_name != self.last_checked_label: print "ButtonArea:", label_name, self.last_checked_label self.last_checked_label = label_name self.update_buttons()
479,100
def clickedLabelButton(self): button = self.get_checked_label_button() label_name = str(button.text()) if label_name != self.last_checked_label: print label_name, self.last_checked_label self.last_checked_label = label_name self.update_buttons()
def clickedLabelButton(self): button = self.get_checked_label_button() label_name = str(button.text()) if label_name != self.last_checked_label: print label_name, self.last_checked_label self.last_checked_label = label_name self.update_buttons()
479,101
def load(self, config_filepath): execfile(config_filepath) #if self.get_checked_label_button() == None: # if len(self.label_buttongroup.buttons()) != 0: # self.label_buttongroup.buttons()[0].setChecked(True) # #self.last_checked_label = str(self.get_checked_label_button().text()) self.update_label_buttons() self.update_buttons()
def load(self, config_filepath): execfile(config_filepath) #if self.get_checked_label_button() == None: # if len(self.label_buttongroup.buttons()) != 0: # self.label_buttongroup.buttons()[0].setChecked(True) # #self.last_checked_label = str(self.get_checked_label_button().text()) self.update_label_buttons() self.update_buttons()
479,102
def load(self, config_filepath): execfile(config_filepath) #if self.get_checked_label_button() == None: # if len(self.label_buttongroup.buttons()) != 0: # self.label_buttongroup.buttons()[0].setChecked(True) # #self.last_checked_label = str(self.get_checked_label_button().text()) self.update_label_buttons() self.update_buttons()
def load(self, config_filepath): execfile(config_filepath) #if self.get_checked_label_button() == None: # if len(self.label_buttongroup.buttons()) != 0: # self.label_buttongroup.buttons()[0].setChecked(True) # #self.last_checked_label = str(self.get_checked_label_button().text()) self.init_button_lists()
479,103
def itemChange(self, change, value): print change if change == QGraphicsItem.ItemScenePositionHasChanged: self.updateModel() return AnnotationGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemScenePositionHasChanged: self.updateModel() return AnnotationGraphicsItem.itemChange(self, change, value)
479,104
def updateModel(self): if not self._delayedDirty(): self.data_['x'] = self.scenePos().x() self.data_['y'] = self.scenePos().y() print "updateModel (point)", self.data_ self.index().model().setData(self.index(), QVariant(self.data_), DataRole)
def updateModel(self): if not self._delayedDirty(): self.data_['x'] = self.scenePos().x() self.data_['y'] = self.scenePos().y() self.index().model().setData(self.index(), QVariant(self.data_), DataRole)
479,105
def __init__(self, scene, model=None): self.scene_ = scene self.mode_ = None
def __init__(self, scene, mode=None): self.scene_ = scene self.mode_ = None
479,106
def __init__(self, scene, model=None): self.scene_ = scene self.mode_ = None
def __init__(self, scene, model=None): self.scene_ = scene self.mode_ = None
479,107
def mousePressEvent(self, event, index): pos = event.scenePos() # TODO create it in the model instead item = QGraphicsEllipseItem(QRectF(pos.x()-1, pos.y()-1, 2, 2)) self.scene().addItem(item)
def mousePressEvent(self, event, index): pos = event.scenePos() # TODO create it in the model instead item = QGraphicsEllipseItem(QRectF(pos.x()-1, pos.y()-1, 2, 2)) self.scene().addItem(item)
479,108
def __init__(self, scene, model=None): ItemInserter.__init__(self, scene, model) self.current_item_ = None self.init_pos_ = None
def __init__(self, scene, mode=None): ItemInserter.__init__(self, scene, mode) self.current_item_ = None self.init_pos_ = None
479,109
def mouseMoveEvent(self, event, index): if self.current_item_ is not None: assert self.init_pos_ is not None pos = event.scenePos() rect = QRectF(self.init_pos_.x(), self.init_pos_.y(), pos.x() - self.init_pos_.x(), pos.y() - self.init_pos_.y()) self.current_item_.setRect(rect.normalized())
def mouseMoveEvent(self, event, index): if self.current_item_ is not None: assert self.init_pos_ is not None pos = event.scenePos() rect = QRectF(self.init_pos_.x(), self.init_pos_.y(), pos.x() - self.init_pos_.x(), pos.y() - self.init_pos_.y()) self.current_item_.setRect(rect.normalized())
479,110
def mouseReleaseEvent(self, event, index): if self.current_item_ is not None: if self.current_item_.rect().width() > 1 and \ self.current_item_.rect().height() > 1: # TODO commit to the model print "added rect:", self.current_item_ rect = self.current_item_.rect() ann = {'type': 'rect', 'x': rect.x(), 'y': rect.y(), 'width': rect.width(), 'height': rect.height()} index.model().addAnnotation(index, ann) self.scene().removeItem(self.current_item_) self.current_item_ = None self.init_pos_ = None
def mouseReleaseEvent(self, event, index): if self.current_item_ is not None: if self.current_item_.rect().width() > 1 and \ self.current_item_.rect().height() > 1: # TODO commit to the modelrect = self.current_item_.rect() ann = {'type': 'rect', 'x': rect.x(), 'y': rect.y(), 'width': rect.width(), 'height': rect.height()} index.model().addAnnotation(index, ann) self.scene().removeItem(self.current_item_) self.current_item_ = None self.init_pos_ = None
479,111
def __init__(self, scene, model=None): ItemInserter.__init__(self, scene, model) self.current_item_ = None
def __init__(self, scene, mode=None): ItemInserter.__init__(self, scene, mode) self.current_item_ = None
479,112
def __init__(self, parent=None): super(AnnotationScene, self).__init__(parent)
def __init__(self, parent=None): super(AnnotationScene, self).__init__(parent)
479,113
def keyPressEvent(self, event): ## handle deletions of items if event.key() == Qt.Key_Delete: index = self.currentIndex() if not index.isValid(): return parent = self.model().parent(index) self.model().removeRow(index.row(), parent)
def keyPressEvent(self, event): ## handle deletions of items if event.key() == Qt.Key_Delete: index = self.currentIndex() if not index.isValid(): return parent = self.model().parent(index) self.model().removeRow(index.row(), parent)
479,114
def gotoNext(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentFileIndex(next_index)
def gotoNext(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentFileIndex(next_index)
479,115
def gotoPrevious(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentFileIndex(next_index)
def gotoPrevious(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentFileIndex(next_index)
479,116
def gotoPrevious(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentIndex(next_index)
def gotoPrevious(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentIndex(next_index)
479,117
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.setRenderHint(QPainter.Antialiasing) self.setRenderHint(QPainter.TextAntialiasing) self.setFrameStyle(QFrame.NoFrame)
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.setRenderHint(QPainter.Antialiasing) self.setRenderHint(QPainter.TextAntialiasing) self.setFrameStyle(QFrame.NoFrame)
479,118
def activate(self): if not self.active_: self.active_ = True self.setFocus(Qt.OtherFocusReason) self.setFrameStyle(QFrame.Panel) self.update()
def activate(self): if not self.active_: self.active_ = True self.setFocus(Qt.OtherFocusReason) self.setStyleSheet("QFrame { border: 3px solid red }"); self.update()
479,119
def deactivate(self): if self.active_: self.active_ = False self.clearFocus() self.setFrameStyle(QFrame.NoFrame) self.update()
def deactivate(self): if self.active_: self.active_ = False self.clearFocus() self.setStyleSheet("QFrame { border: 3px solid black }"); self.update()
479,120
def update_buttons(self): layout = self.hlayout.takeAt(1)
def update_buttons(self): layout = self.hlayout.takeAt(1)
479,121
def set_bands(self, bands, current):
def set_bands(self, bands, current):
479,122
def set_prefs(self, prefs, current): model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
def set_prefs(self, modes, current): model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
479,123
def set_prefs(self, prefs, current): model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
def set_prefs(self, prefs, current): model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
479,124
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'number': '*99#', 'apn': self.apn.strip()}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'number': '*99#', 'apn': self.apn.strip()}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
479,125
def run(self): for filename in glob(join('.', 'resources', 'po', '*.po')): lang = basename(filename)[:-3]
def run(self): for filename in glob(join('.', 'resources', 'po', '*.po')): lang = basename(filename)[:-3]
479,126
def __init__(self, ctrl):
def __init__(self, ctrl):
479,127
def sim_network(sim_data): # let's look up what we think this SIM's network is. # so we want to display the country and network operator
def sim_network(sim_data): # let's look up what we think this SIM's network is. # so we want to display the country and network operator
479,128
def sim_imsi(sim_data): # ok we don't have a model the data is coming from dbus from the # core lets tell the view to set the imei in the correct place logger.info("payt-controller sim_imsi - IMSI number is: %s" % sim_data) # FIXME - Removed not needed yet #self.view.set_imsi_info(sim_data)
def sim_imsi(sim_data): # ok we don't have a model the data is coming from dbus from the # core lets tell the view to set the imei in the correct place logger.info("payt-controller sim_imsi - IMSI number is: %s" % sim_data) # FIXME - Removed not needed yet #self.view.set_imsi_info(sim_data)
479,129
def check_voucher_update_response(self, ussd_voucher_update_response): device = self.model.get_device() # ok my job is to work out what happened after a credit voucher update message was sent. # we can have three possibilities, it was succesfull, the voucher code was wrong, or you tried with # an illegal number too many times. For now I only do something when it works, the other two # possibilities I just report the error provided by the network. if (ussd_voucher_update_response.find('TopUp successful') == -1): # ok we got a -1 from our 'find' so it failed just log for now as we report the message to the view no matter what happens. logger.info("payt-controoler check_voucher_update_response - topup failed: " + ussd_voucher_update_response)
def check_voucher_update_response(self, ussd_voucher_update_response): device = self.model.get_device() # ok my job is to work out what happened after a credit voucher update message was sent. # we can have three possibilities, it was succesfull, the voucher code was wrong, or you tried with # an illegal number too many times. For now I only do something when it works, the other two # possibilities I just report the error provided by the network. if (ussd_voucher_update_response.find('TopUp successful') == -1): # ok we got a -1 from our 'find' so it failed just log for now as we report the message to the view no matter what happens. logger.info("payt-controoler check_voucher_update_response - topup failed: " + ussd_voucher_update_response)
479,130
def save(self):
def save(self):
479,131
def get_transferred_gprs(self, offset): # filter out all the items that respond True to "is_gprs" gprs_items = [item for item in self._get_month(offset) if item.is_gprs] # get a list with the total transferred for every item and sum them up result = sum((item.total() for item in gprs_items)) if offset == 0: result += self.twog_session return result
def get_transferred_gprs(self, offset): # filter out all the items that respond True to "is_gprs" gprs_items = [item for item in self._get_month(offset) if item.is_gprs()] # get a list with the total transferred for every item and sum them up result = sum((item.total() for item in gprs_items)) if offset == 0: result += self.twog_session return result
479,132
def setup_view(self): self.get_top_widget().set_position(gtk.WIN_POS_CENTER_ON_PARENT) self['sim_image'].set_from_file(self.Sim_Image) self['payt_image'].set_from_file(self.Computer_Image) self['credit_card_image'].set_from_file(self.Modem_Image) self['voucher_image'].set_from_file(self.Betavine_Image)
def setup_view(self): self.get_top_widget().set_position(gtk.WIN_POS_CENTER_ON_PARENT) self['sim_image'].set_from_file(self.sim_image) self['payt_image'].set_from_file(self.Computer_Image) self['credit_card_image'].set_from_file(self.Modem_Image) self['voucher_image'].set_from_file(self.Betavine_Image)
479,133
def get_msisdn(self, cb): if self.msisdn: logger.info("MSISDN from model cache %s: " % self.msisdn) cb(self.msisdn) return
def get_msisdn(self, cb): if self.msisdn: logger.info("MSISDN from model cache: %s" % self.msisdn) cb(self.msisdn) return
479,134
def get_imsi_cb(imsi): if imsi: msisdn = self.conf.get("sim/%s" % imsi, 'msisdn') if msisdn: logger.info("MSISDN from gconf %s: " % msisdn) self.msisdn = msisdn cb(self.msisdn) return
def get_imsi_cb(imsi): if imsi: msisdn = self.conf.get("sim/%s" % imsi, 'msisdn') if msisdn: logger.info("MSISDN from gconf: %s" % msisdn) self.msisdn = msisdn cb(self.msisdn) return
479,135
def get_profiles(self): ret = {} for profile in self.manager.get_profiles(): settings = profile.get_settings() # filter out wlan profiles if 'ppp' in settings: uuid = settings['connection']['uuid'] ret[uuid] = ProfileModel(self, profile=profile, device_callable=self.device_callable, parent_model_callable=self.parent_model_callable) return ret
def get_profiles(self): ret = {} for profile in self.manager.get_profiles(): settings = profile.get_settings() # filter out wlan profilesuuid = settings['connection']['uuid'] ret[uuid] = ProfileModel(self, profile=profile, device_callable=self.device_callable, parent_model_callable=self.parent_model_callable) return ret
479,136
def __ne__(self, other): if other is None: return True return self.uuid != other.uuid
def __ne__(self, other): if other is None: return True return self.uuid != other.uuid
479,137
def _load_settings(self, settings): try: self.uuid = settings['connection']['uuid'] self.name = settings['connection']['id'] self.username = settings['gsm']['username'] self.apn = settings['gsm']['apn'] self.autoconnect = settings['connection'].get('autoconnect', False) self.static_dns = settings['ipv4'].get('ignore-auto-dns') if settings['ipv4'].get('dns', None): dns = settings['ipv4'].get('dns') self.primary_dns = dns[0] if len(dns) > 1: self.secondary_dns = dns[1]
def _load_settings(self, settings): try: self.uuid = settings['connection']['uuid'] self.name = settings['connection']['id'] self.username = settings['gsm'].get('username', '') self.apn = settings['gsm']['apn'] self.autoconnect = settings['connection'].get('autoconnect', False) self.static_dns = settings['ipv4'].get('ignore-auto-dns') if settings['ipv4'].get('dns', None): dns = settings['ipv4'].get('dns') self.primary_dns = dns[0] if len(dns) > 1: self.secondary_dns = dns[1]
479,138
def _load_settings(self, settings): try: self.uuid = settings['connection']['uuid'] self.name = settings['connection']['id'] self.username = settings['gsm']['username'] self.apn = settings['gsm']['apn'] self.autoconnect = settings['connection'].get('autoconnect', False) self.static_dns = settings['ipv4'].get('ignore-auto-dns') if settings['ipv4'].get('dns', None): dns = settings['ipv4'].get('dns') self.primary_dns = dns[0] if len(dns) > 1: self.secondary_dns = dns[1]
def _load_settings(self, settings): try: self.uuid = settings['connection']['uuid'] self.name = settings['connection']['id'] self.username = settings['gsm']['username'] self.apn = settings['gsm']['apn'] self.autoconnect = settings['connection'].get('autoconnect', False) self.static_dns = settings['ipv4'].get('ignore-auto-dns') if settings['ipv4'].get('dns', None): dns = settings['ipv4'].get('dns') self.primary_dns = dns[0] if len(dns) > 1: self.secondary_dns = dns[1]
479,139
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'band': self.band, 'username': self.username, 'number': '*99#', 'network-type': self.network_pref, 'apn': self.apn}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'number': '*99#', 'network-type': self.network_pref, 'apn': self.apn}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
479,140
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'band': self.band, 'username': self.username, 'number': '*99#', 'network-type': self.network_pref, 'apn': self.apn}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'band': self.band, 'username': self.username, 'number': '*99#', 'apn': self.apn}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
479,141
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'band': self.band, 'username': self.username, 'number': '*99#', 'network-type': self.network_pref, 'apn': self.apn}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'band': self.band, 'username': self.username, 'number': '*99#', 'network-type': self.network_pref, 'apn': self.apn}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
479,142
def property_device_value_change(self, model, old, new): if self.model.device is not None: sm = self.model.device.connect_to_signal("DeviceEnabled", self.on_device_enabled_cb) self.signal_matches.append(sm) # connect to SIG_SMS_COMP and display SMS sm = self.model.device.connect_to_signal(SIG_SMS_COMP, self.on_sms_received_cb) self.signal_matches.append(sm) else: while self.signal_matches: sm = self.signal_matches.pop() sm.remove() self.view['connect_button'].set_sensitive(False) self.view['topup_tool_button'].set_sensitive(False) logger.info("main-controller: property_device_value_change - device : " + self.model.device)
def property_device_value_change(self, model, old, new): if self.model.device is not None: sm = self.model.device.connect_to_signal("DeviceEnabled", self.on_device_enabled_cb) self.signal_matches.append(sm) # connect to SIG_SMS_COMP and display SMS sm = self.model.device.connect_to_signal(SIG_SMS_COMP, self.on_sms_received_cb) self.signal_matches.append(sm) else: while self.signal_matches: sm = self.signal_matches.pop() sm.remove() self.view['connect_button'].set_sensitive(False) self.view['topup_tool_button'].set_sensitive(False) logger.info("main-controller: property_device_value_change - device : " + self.model.device)
479,143
def nick_debug(s): if 1: with open(BCM_FAST_LOG, 'a', 0) as f: f.write("%s\n" % s)
def nick_debug(s): if 0: with open(BCM_FAST_LOG, 'a', 0) as f: f.write("%s\n" % s)
479,144
def ask_for_new_profile(self): nick_debug("main.py: controller - ask_for_new_profile called") logger.info("main.py: controller - ask_for_new_profile called")
defask_for_new_profile(self):nick_debug("main.py:controller-ask_for_new_profilecalled")logger.info("main.py:controller-ask_for_new_profilecalled")
479,145
def _generate_customer_support_text(self, imsi): utxt = '"' + _('Unknown') + '"' args = {'url':APP_URL, 'shortcode':utxt, 'international':utxt}
def _generate_customer_support_text(self, imsi): utxt = '"' + _('Unknown') + '"' args = {'url':APP_URL, 'shortcode':utxt, 'international':utxt}
479,146
def property_profile_required_value_change(self, model, old, new): logger.info("main.py: controller - property_profile value changed - begining method") if new: logger.info("main.py: controller - property_profile value changed - calling 'ask_for_new_profile' ") self.ask_for_new_profile()
def property_profile_required_value_change(self, model, old, new): logger.info("main.py: controller - property_profile value changed" " - begining method") if new: logger.info("main.py: controller - property_profile value changed - calling 'ask_for_new_profile' ") self.ask_for_new_profile()
479,147
def property_profile_required_value_change(self, model, old, new): logger.info("main.py: controller - property_profile value changed - begining method") if new: logger.info("main.py: controller - property_profile value changed - calling 'ask_for_new_profile' ") self.ask_for_new_profile()
def property_profile_required_value_change(self, model, old, new): logger.info("main.py: controller - property_profile value changed - begining method") if new: logger.info("main.py: controller - property_profile value " "changed - calling 'ask_for_new_profile' ") self.ask_for_new_profile()
479,148
def on_mm_props_change_cb(self, ifname, ifprops): if ifname == consts.NET_INTFACE and 'AccessTechnology' in ifprops: self.model.tech = self._map_access_tech(ifprops['AccessTechnology']) logger.info("TECH changed %s", self.model.tech)
def on_mm_props_change_cb(self, ifname, ifprops): if ifname == consts.NET_INTFACE and 'AccessTechnology' in ifprops: self.model.tech = self._map_access_tech( ifprops['AccessTechnology']) logger.info("TECH changed %s", self.model.tech)
479,149
def on_device_enabled_cb(self, opath): self.model.status = _('Scanning') self.model.pin_is_enabled(self.on_is_pin_enabled_cb, lambda *args: True)
def on_device_enabled_cb(self, opath): self.model.status = _('Scanning') self.model.pin_is_enabled(self.on_is_pin_enabled_cb, lambda *args: True)
479,150
def property_status_value_change(self, model, old, new): if new == _('Initialising'): self.view.set_initialising(True) elif new == _('No device'): self.view.set_disconnected(device_present=False) elif new in [_('Registered'), _('Roaming')]: self.view.set_initialising(False)
def property_status_value_change(self, model, old, new): if new == _('Initialising'): self.view.set_initialising(True) elif new == _('No device'): self.view.set_disconnected() elif new in [_('Registered'), _('Roaming')]: self.view.set_initialising(False)
479,151
def enable_send_button(self, sensitive): self['button2'].set_sensitive(sensitive)
def enable_send_button(self, sensitive): self['button2'].set_sensitive(sensitive)
479,152
def _check_result(req, result): """ Check that a page handler actually wrote something, and properly finish the apache request.""" if result or req.bytes_sent > 0: if result is None: result = "" else: result = str(result) # unless content_type was manually set, we will attempt # to guess it if not req.content_type_set_p: # make an attempt to guess content-type if result[:100].strip()[:6].lower() == '<html>' \ or result.find('</') > 0: req.content_type = 'text/html' else: req.content_type = 'text/plain' if req.header_only: if req.status in (apache.HTTP_NOT_FOUND, ): raise apache.SERVER_RETURN, req.status else: req.write(result) return apache.OK else: req.log_error("publisher: %s returned nothing." % `object`) return apache.HTTP_INTERNAL_SERVER_ERROR
def _check_result(req, result): """ Check that a page handler actually wrote something, and properly finish the apache request. @param req: the request. @param result: the produced output. @type result: string @return: an apache error code @rtype: int @raise apache.SERVER_RETURN: in case of a HEAD request. @note: that this function actually takes care of writing the result to the client. """ if result or req.bytes_sent > 0: if result is None: result = "" else: result = str(result) # unless content_type was manually set, we will attempt # to guess it if not req.content_type_set_p: # make an attempt to guess content-type if result[:100].strip()[:6].lower() == '<html>' \ or result.find('</') > 0: req.content_type = 'text/html' else: req.content_type = 'text/plain' if req.header_only: if req.status in (apache.HTTP_NOT_FOUND, ): raise apache.SERVER_RETURN, req.status else: req.write(result) return apache.OK else: req.log_error("publisher: %s returned nothing." % `object`) return apache.HTTP_INTERNAL_SERVER_ERROR
479,153
def _check_result(req, result): """ Check that a page handler actually wrote something, and properly finish the apache request.""" if result or req.bytes_sent > 0: if result is None: result = "" else: result = str(result) # unless content_type was manually set, we will attempt # to guess it if not req.content_type_set_p: # make an attempt to guess content-type if result[:100].strip()[:6].lower() == '<html>' \ or result.find('</') > 0: req.content_type = 'text/html' else: req.content_type = 'text/plain' if req.header_only: if req.status in (apache.HTTP_NOT_FOUND, ): raise apache.SERVER_RETURN, req.status else: req.write(result) return apache.OK else: req.log_error("publisher: %s returned nothing." % `object`) return apache.HTTP_INTERNAL_SERVER_ERROR
def_check_result(req,result):"""Checkthatapagehandleractuallywrotesomething,andproperlyfinishtheapacherequest."""ifresultorreq.bytes_sent>0:ifresultisNone:result=""else:result=str(result)#unlesscontent_typewasmanuallyset,wewillattempt#toguessitifnotreq.content_type_set_p:#makeanattempttoguesscontent-typeifresult[:100].strip()[:6].lower()=='<html>'\orresult.find('</')>0:req.content_type='text/html'else:req.content_type='text/plain'ifreq.header_only:ifreq.statusin(apache.HTTP_NOT_FOUND,):raiseapache.SERVER_RETURN,req.statuselse:req.write(result)returnapache.OKelse:req.log_error("publisher:%sreturnednothing."%`object`)returnapache.HTTP_INTERNAL_SERVER_ERROR
479,154
def _check_result(req, result): """ Check that a page handler actually wrote something, and properly finish the apache request.""" if result or req.bytes_sent > 0: if result is None: result = "" else: result = str(result) # unless content_type was manually set, we will attempt # to guess it if not req.content_type_set_p: # make an attempt to guess content-type if result[:100].strip()[:6].lower() == '<html>' \ or result.find('</') > 0: req.content_type = 'text/html' else: req.content_type = 'text/plain' if req.header_only: if req.status in (apache.HTTP_NOT_FOUND, ): raise apache.SERVER_RETURN, req.status else: req.write(result) return apache.OK else: req.log_error("publisher: %s returned nothing." % `object`) return apache.HTTP_INTERNAL_SERVER_ERROR
def _check_result(req, result): """ Check that a page handler actually wrote something, and properly finish the apache request.""" if result or req.bytes_sent > 0: if result is None: result = "" else: result = str(result) # unless content_type was manually set, we will attempt # to guess it if not req.content_type_set_p: # make an attempt to guess content-type if result[:100].strip()[:6].lower() == '<html>' \ or result.find('</') > 0: req.content_type = 'text/html' else: req.content_type = 'text/plain' if req.header_only: if req.status in (apache.HTTP_NOT_FOUND, ): raise apache.SERVER_RETURN, req.status else: req.write(result) return apache.OK else: req.log_error("publisher: %s returned nothing." % `object`) return apache.HTTP_INTERNAL_SERVER_ERROR
479,155
def _check_result(req, result): """ Check that a page handler actually wrote something, and properly finish the apache request.""" if result or req.bytes_sent > 0: if result is None: result = "" else: result = str(result) # unless content_type was manually set, we will attempt # to guess it if not req.content_type_set_p: # make an attempt to guess content-type if result[:100].strip()[:6].lower() == '<html>' \ or result.find('</') > 0: req.content_type = 'text/html' else: req.content_type = 'text/plain' if req.header_only: if req.status in (apache.HTTP_NOT_FOUND, ): raise apache.SERVER_RETURN, req.status else: req.write(result) return apache.OK else: req.log_error("publisher: %s returned nothing." % `object`) return apache.HTTP_INTERNAL_SERVER_ERROR
def _check_result(req, result): """ Check that a page handler actually wrote something, and properly finish the apache request.""" if result or req.bytes_sent > 0: if result is None: result = "" else: result = str(result) # unless content_type was manually set, we will attempt # to guess it if not req.content_type_set_p: # make an attempt to guess content-type if result[:100].strip()[:6].lower() == '<html>' \ or result.find('</') > 0: req.content_type = 'text/html' else: req.content_type = 'text/plain' if req.header_only: if req.status in (apache.HTTP_NOT_FOUND, ): raise apache.SERVER_RETURN, req.status else: req.write(result) return apache.OK else: req.log_error("publisher: %s returned nothing." % `object`) return apache.HTTP_INTERNAL_SERVER_ERROR
479,156
def _traverse(self, req, path, do_head=False, guest_p=True): """ Locate the handler of an URI by traversing the elements of the path."""
def _traverse(self, req, path, do_head=False, guest_p=True): """ Locate the handler of an URI by traversing the elements of the path."""
479,157
def _traverse(self, req, path, do_head=False, guest_p=True): """ Locate the handler of an URI by traversing the elements of the path."""
def _traverse(self, req, path, do_head=False, guest_p=True): """ Locate the handler of an URI by traversing the elements of the path."""
479,158
def _traverse(self, req, path, do_head=False, guest_p=True): """ Locate the handler of an URI by traversing the elements of the path."""
def _traverse(self, req, path, do_head=False, guest_p=True): """ Locate the handler of an URI by traversing the elements of the path."""
479,159
def _traverse(self, req, path, do_head=False, guest_p=True): """ Locate the handler of an URI by traversing the elements of the path."""
def _traverse(self, req, path, do_head=False, guest_p=True): """ Locate the handler of an URI by traversing the elements of the path."""
479,160
def __call__(self, req, form): """ Maybe resolve the final / of a directory """
def __call__(self, req, form): """ Maybe resolve the final / of a directory """
479,161
def __call__(self, req, form): """ Maybe resolve the final / of a directory """
def __call__(self, req, form): """ Maybe resolve the final / of a directory """
479,162
def _profiler(req): """ This handler wrap the default handler with a profiler. Profiling data is written into CFG_TMPDIR/invenio-profile-stats-datetime.raw, and is displayed at the bottom of the webpage. To use add profile=1 to your url. To change sorting algorithm you can provide profile=algorithm_name. You can add more than one profile requirement like ?profile=time&profile=cumulative. The list of available algorithm is displayed at the end of the profile. """ args = {} if req.args: args = cgi.parse_qs(req.args) if 'profile' in args: if not isUserSuperAdmin(collect_user_info(req)): return _handler(req)
def _profiler(req): """ This handler wrap the default handler with a profiler. Profiling data is written into CFG_TMPDIR/invenio-profile-stats-datetime.raw, and is displayed at the bottom of the webpage. To use add profile=1 to your url. To change sorting algorithm you can provide profile=algorithm_name. You can add more than one profile requirement like ?profile=time&profile=cumulative. The list of available algorithm is displayed at the end of the profile. """ args = {} if req.args: args = cgi.parse_qs(req.args) if 'profile' in args: if not isUserSuperAdmin(collect_user_info(req)): return _handler(req)
479,163
def _profiler(req): """ This handler wrap the default handler with a profiler. Profiling data is written into CFG_TMPDIR/invenio-profile-stats-datetime.raw, and is displayed at the bottom of the webpage. To use add profile=1 to your url. To change sorting algorithm you can provide profile=algorithm_name. You can add more than one profile requirement like ?profile=time&profile=cumulative. The list of available algorithm is displayed at the end of the profile. """ args = {} if req.args: args = cgi.parse_qs(req.args) if 'profile' in args: if not isUserSuperAdmin(collect_user_info(req)): return _handler(req)
def _profiler(req): """ This handler wrap the default handler with a profiler. Profiling data is written into CFG_TMPDIR/invenio-profile-stats-datetime.raw, and is displayed at the bottom of the webpage. To use add profile=1 to your url. To change sorting algorithm you can provide profile=algorithm_name. You can add more than one profile requirement like ?profile=time&profile=cumulative. The list of available algorithm is displayed at the end of the profile. """ args = {} if req.args: args = cgi.parse_qs(req.args) if 'profile' in args: if not isUserSuperAdmin(collect_user_info(req)): return _handler(req)
479,164
def _handler(req): """ This handler is invoked by mod_python with the apache request.""" try: allowed_methods = ("GET", "POST", "HEAD", "OPTIONS") req.allow_methods(allowed_methods, 1) if req.method not in allowed_methods: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED
def _handler(req): """ This handler is invoked by mod_python with the apache request.""" try: allowed_methods = ("GET", "POST", "HEAD", "OPTIONS") req.allow_methods(allowed_methods, 1) if req.method not in allowed_methods: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED
479,165
def _handler(req): """ This handler is invoked by mod_python with the apache request.""" try: allowed_methods = ("GET", "POST", "HEAD", "OPTIONS") req.allow_methods(allowed_methods, 1) if req.method not in allowed_methods: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED
def _handler(req): """ This handler is invoked by mod_python with the apache request.""" try: allowed_methods = ("GET", "POST", "HEAD", "OPTIONS") req.allow_methods(allowed_methods, 1) if req.method not in allowed_methods: raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED
479,166
def _traverse(self, req, path): """ Locate the handler of an URI by traversing the elements of the path."""
def _traverse(self, req, path): """ Locate the handler of an URI by traversing the elements of the path."""
479,167
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** form = dict(req.form) for key, value in form.items(): ## FIXME: this is a backward compatibility workaround ## because most of the old administration web handler ## expect parameters to be of type str. ## When legacy publisher will be removed all this ## pain will go away anyway :-) if isinstance(value, str): form[key] = str(value) try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue cleaned_form[arg] = form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** form = dict(req.form) for key, value in form.items(): ## FIXME: this is a backward compatibility workaround ## because most of the old administration web handler ## expect parameters to be of type str. ## When legacy publisher will be removed all this ## pain will go away anyway :-) if isinstance(value, str): form[key] = str(value) try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect inspected_args = inspect.getargspec(module_globals[possible_handler]) expected_args = list(inspected_args[0]) expected_defaults = list(inspected_args[3]) expected_args.reverse() expected_defaults.reverse() register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue cleaned_form[arg] = form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
479,168
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** form = dict(req.form) for key, value in form.items(): ## FIXME: this is a backward compatibility workaround ## because most of the old administration web handler ## expect parameters to be of type str. ## When legacy publisher will be removed all this ## pain will go away anyway :-) if isinstance(value, str): form[key] = str(value) try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue cleaned_form[arg] = form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** form = dict(req.form) for key, value in form.items(): ## FIXME: this is a backward compatibility workaround ## because most of the old administration web handler ## expect parameters to be of type str. ## When legacy publisher will be removed all this ## pain will go away anyway :-) if isinstance(value, str): form[key] = str(value) try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for index, arg in enumerate(expected_args): if arg == 'req': continue cleaned_form[arg] = form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
479,169
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** form = dict(req.form) for key, value in form.items(): ## FIXME: this is a backward compatibility workaround ## because most of the old administration web handler ## expect parameters to be of type str. ## When legacy publisher will be removed all this ## pain will go away anyway :-) if isinstance(value, str): form[key] = str(value) try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue cleaned_form[arg] = form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** form = dict(req.form) for key, value in form.items(): ## FIXME: this is a backward compatibility workaround ## because most of the old administration web handler ## expect parameters to be of type str. ## When legacy publisher will be removed all this ## pain will go away anyway :-) if isinstance(value, str): form[key] = str(value) try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue if index < len(expected_defaults): cleaned_form[arg] = form.get(arg, expected_defaults[index]) else: cleaned_form[arg] = form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
479,170
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** try: return _check_result(req, module_globals[possible_handler](req, **dict(req.form))) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue cleaned_form[arg] = req.form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue cleaned_form[arg] = req.form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
479,171
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** try: return _check_result(req, module_globals[possible_handler](req, **dict(req.form))) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue cleaned_form[arg] = req.form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} exec(the_module, module_globals) if possible_handler in module_globals and callable(module_globals[possible_handler]): from invenio.webinterface_handler import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** try: return _check_result(req, module_globals[possible_handler](req, **dict(req.form))) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect expected_args = inspect.getargspec(module_globals[possible_handler])[0] register_exception(req=req, prefix="Wrong GET parameter set in calling a legacy publisher handler for %s: expected_args=%s, found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())), alert_admin=CFG_DEVEL_SITE) cleaned_form = {} for arg in expected_args: if arg == 'req': continue cleaned_form[arg] = form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise else: raise SERVER_RETURN, HTTP_NOT_FOUND
479,172
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if song['file'] in pl: client.play(pl.index(song['file'])) else: client.add(song['file']) client.play(len(pl)) #length one higher now, with added song client.close() client.disconnect()
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if(pl): idx = client.playlist().index(client.currentsong()['file']) client.addid(song['file'], idx+1) client.play(idx+1) else: client.add(song['file']) client.play(len(pl)) #length one higher now, with added song client.close() client.disconnect()
479,173
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if song['file'] in pl: client.play(pl.index(song['file'])) else: client.add(song['file']) client.play(len(pl)) #length one higher now, with added song client.close() client.disconnect()
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if song['file'] in pl: client.play(pl.index(song['file'])) else: client.add(song['file']) client.play() #length one higher now, with added song client.close() client.disconnect()
479,174
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if song['file'] in pl: client.play(pl.index(song['file'])) else: client.add(song['file']) client.play(len(pl)) #length one higher now, with added song client.close() client.disconnect()
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if song['file'] in pl: client.play(pl.index(song['file'])) else: client.add(song['file']) client.play(len(pl)) #length one higher now, with added song client.close() client.disconnect()
479,175
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if song['file'] in pl: client.play(pl.index(song['file'])) else: client.add(song['file']) client.play(len(pl)) #length one higher now, with added song client.close() client.disconnect()
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if song['file'] in pl: client.play(pl.index(song['file'])) else: client.add(song['file']) client.play(len(pl)) #length one higher now, with added song client.close() client.disconnect()
479,176
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if(pl): idx = client.playlist().index(client.currentsong()['file']) client.addid(song['file'], idx+1) client.play(idx+1) #length one higher now, with added song else: client.add(song['file']) client.play() client.close() client.disconnect()
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() cur = client.currentsong() if(pl and cur): idx = client.playlist().index(cur['file']) client.addid(song['file'], idx+1) client.play(idx+1) #length one higher now, with added song else: client.add(song['file']) client.play() client.close() client.disconnect()
479,177
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if(pl): idx = client.playlist().index(client.currentsong()['file']) client.addid(song['file'], idx+1) client.play(idx+1) #length one higher now, with added song else: client.add(song['file']) client.play() client.close() client.disconnect()
def playSong(key): client.connect(mpdHost, mpdPort) client.password(mpdPass) songs = songLookup[key] song = songs[random.randint(0, len(songs)-1)] pl = client.playlist() if(pl): idx = client.playlist().index(client.currentsong()['file']) client.addid(song['file'], idx+1) client.play(idx+1) #length one higher now, with added song else: client.add(song['file']) client.play(len(pl)) client.close() client.disconnect()
479,178
def retrieveData(self): sfbc = getToolByName(self.context, 'portal_salesforcebaseconnector') sfa = self.getRelevantSFAdapter() if sfa is None: return {} sObjectType = sfa.getSFObjectType() econtext = getExprContext(sfa) econtext.setGlobal('sanitize_soql', sanitize_soql) updateMatchExpression = sfa.getUpdateMatchExpression(expression_context = econtext) mappings = sfa.getFieldMap()
def retrieveData(self): sfbc = getToolByName(self.context, 'portal_salesforcebaseconnector') sfa = self.getRelevantSFAdapter() if sfa is None: return {} sObjectType = sfa.getSFObjectType() econtext = getExprContext(sfa) econtext.setGlobal('sanitize_soql', sanitize_soql) updateMatchExpression = sfa.getUpdateMatchExpression(expression_context = econtext) mappings = sfa.getFieldMap()
479,179
def startup (self): global CXXFLAGS, TARGET
def startup (self): global CXXFLAGS, TARGET
479,180
def detect_platform (): global HOST, TARGET, DEVNULL if sys.platform [:3] == "win": HOST = ["windows"] TARGET = ["windows"] DEVNULL = "nul" elif sys.platform [:6] == "darwin": HOST = ["mac"] TARGET = ["mac"] DEVNULL = "/dev/null" else: # Default to POSIX HOST = ["posix"] TARGET = ["posix"] DEVNULL = "/dev/null" arch = platform.machine () # Python 2.5 on windows returns empty string here if (arch == "") or \ (len (arch) >= 4 and arch [0] == "i" and arch [2:4] == "86" and arch [4:] == ""): arch = "x86" HOST.append (arch) TARGET.append (arch) cpu = platform.processor () if (not cpu) or (len (cpu) == 0): cpu = platform.machine () TARGET.append (cpu.replace ("-", "_")) # HOST contains ["platform", "arch"] # TARGET contains ["platform", "arch", "tune"]
def detect_platform (): global HOST, TARGET, DEVNULL if sys.platform [:3] == "win": HOST = ["windows"] TARGET = ["windows"] DEVNULL = "nul" elif sys.platform [:6] == "darwin": HOST = ["mac"] TARGET = ["mac"] DEVNULL = "/dev/null" else: # Default to POSIX HOST = ["posix"] TARGET = ["posix"] DEVNULL = "/dev/null" arch = platform.machine () # Python 2.5 on windows returns empty string here if (arch == "") or \ (len (arch) >= 4 and arch [0] == "i" and arch [2:4] == "86" and arch [4:] == ""): arch = "x86" HOST.append (arch) TARGET.append (arch) TARGET.append (platform.machine ()) # HOST contains ["platform", "arch"] # TARGET contains ["platform", "arch", "tune"]
479,181
def check_cflags (cflags, var, xcflags = ""): """Check if compiler supports certain flags. This is done by creating a dummy source file and trying to compile it using the requested flags. :Parameters: `cflags` : str The compiler flags to check for `var` : str The name of the variable to append the flags to in the case if the flags are supported (e.g. "CFLAGS", "CXXFLAGS" etc) `xcflags` : str Additional flags to use during test compilation. These won't be appended to var. :Returns: True if the flags are supported, False if not. """ check_started ("Checking if compiler supports " + cflags) if var == "CFLAGS": srcf = "conftest.c" else: srcf = "conftest.cpp" write_file (srcf, """
def check_cflags (cflags, var, xcflags = ""): """Check if compiler supports certain flags. This is done by creating a dummy source file and trying to compile it using the requested flags. :Parameters: `cflags` : str The compiler flags to check for `var` : str The name of the variable to append the flags to in the case if the flags are supported (e.g. "CFLAGS", "CXXFLAGS" etc) `xcflags` : str Additional flags to use during test compilation. These won't be appended to var. :Returns: True if the flags are supported, False if not. """ check_started ("Checking if compiler supports " + cflags) if var.endswith ("CFLAGS"): srcf = "conftest.c" else: srcf = "conftest.cpp" write_file (srcf, """
479,182
def check_header (hdr, cflags = None, reqtext = None): """Check if a header file is available to the compiler. This is done by creating a dummy source file and trying to compile it. :Parameters: `hdr` : str The name of the header file to check for `reqtext` : str The message to print in the fatal error message when the header file is not available. If it is None, the missing file is not considered a fatal error. :Returns: True if header file exists, False if not. """ rc = False check_started ("Checking for header file " + hdr) write_file ("conftest.c", """
def check_header (hdr, cflags = None, reqtext = None): """Check if a header file is available to the compiler. This is done by creating a dummy source file and trying to compile it. :Parameters: `hdr` : str The name of the header file to check for `reqtext` : str The message to print in the fatal error message when the header file is not available. If it is None, the missing file is not considered a fatal error. :Returns: True if header file exists, False if not. """ rc = False check_started ("Checking for header file " + hdr) write_file ("conftest.c", """
479,183
def linklib (self, library, path = None): tmp = "" if path: tmp = "-libpath:" + path.replace ('/', '\\\\') + " " return tmp + ".lib ".join (library.split ()) + ".lib"
def linklib (self, library, path = None): tmp = "" if path: tmp = "-libpath:" + path.replace ('/', '\\\\') + " " return tmp + ".lib ".join (library.split ()) + ".lib"
479,184
def start (): global HOST, TARGET, EXE, TOOLKIT global PREFIX, BINDIR, LIBDIR, SYSCONFDIR, DATADIR, DOCDIR global INCLUDEDIR, LIBEXECDIR, SHAREDLIBS detect_platform () # Read environment variables first for e in ENVARS: globals () [e [0]] = os.getenv (e [0], e [1]) # Parse command-line skip_opt = False for optidx in range (1, len (sys.argv)): if skip_opt: skip_opt = False continue opt = sys.argv [optidx] optarg = None opt_ok = False if opt [:2] == "--": opt = opt [2:] opt_short = False for o in OPTIONS: if o [1] and o [1] == opt [:len (o [1])]: optarg = opt [len (o [1]):] if optarg [:1] == '=' or len (opt) == len (o [1]): opt_ok = True optarg = optarg [1:] break elif opt [:1] == "-": opt = opt [1:] opt_short = True for o in OPTIONS: if o [0] and o [0] == opt: opt_ok = True break if not opt_ok: print "Unknown command-line option: '" + opt + "'" sys.exit (1) # Check if option needs argument if o [2] and opt_short: if optidx >= len (sys.argv): print "Option '" + opt + "' needs an argument" sys.exit (1) skip_opt = True optarg = sys.argv [optidx + 1] if not o [2] and optarg: print "Option '" + opt + "' does not accept an argument" sys.exit (1) exec o [3] # Print the host and target platforms print "Compiling on host " + ".".join (HOST) + " for target " + \ ".".join (TARGET [:2]) + " (tune for " + TARGET [2] + ")" # Now set target-specific defaults if TARGET [0] == "windows": EXE = ".exe" else: EXE = "" add_config_h ("CONF_PACKAGE", '"' + PROJ + '"') add_config_mak ("CONF_PACKAGE", PROJ) add_config_h ("CONF_VERSION", '"' + VERSION + '"') add_config_mak ("CONF_VERSION", VERSION) add_config_h ("PLATFORM_" + TARGET [0].upper ()) add_config_h ("ARCH_" + TARGET [1].upper ()) add_config_h ("TUNE_" + TARGET [2].upper ()) add_config_mak ("HOST", HOST [0]) add_config_mak ("TARGET", TARGET [0]) add_config_mak ("ARCH", TARGET [1]) add_config_mak ("TUNE", TARGET [2]) if BINDIR is None: BINDIR = PREFIX + "/bin" if SYSCONFDIR is None: SYSCONFDIR = PREFIX + "/etc/" + PROJ if DATADIR is None: DATADIR = PREFIX + "/share/" + PROJ if DOCDIR is None: DOCDIR = PREFIX + "/share/doc/" + PROJ + "-" + VERSION # http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64 if LIBDIR is None: if TARGET [1] [-2:] == "64": LIBDIR = PREFIX + "/lib64" # Debian doesn't follow LFS in this regard try: os.stat (LIBDIR) except: LIBDIR = PREFIX + "/lib" else: LIBDIR = PREFIX + "/lib" if INCLUDEDIR is None: INCLUDEDIR = PREFIX + "/include" if LIBEXECDIR is None: LIBEXECDIR = PREFIX + "/libexec/" + PROJ # Instantiate the compiler-dependent class TOOLKIT = COMPILERS.get (COMPILER); if not TOOLKIT: print "Unsupported compiler: " + COMPILER sys.exit (1) TOOLKIT = TOOLKIT () TOOLKIT.startup () add_config_h ("CONF_COMPILER_" + COMPILER) if PREFIX != "": add_config_h ("CONF_PREFIX", '"' + PREFIX + '"') add_config_mak ("CONF_PREFIX", PREFIX + '/') if BINDIR != "": add_config_h ("CONF_BINDIR", '"' + BINDIR + '"') add_config_mak ("CONF_BINDIR", BINDIR + '/') if SYSCONFDIR != "": add_config_h ("CONF_SYSCONFDIR", '"' + SYSCONFDIR + '"') add_config_mak ("CONF_SYSCONFDIR", SYSCONFDIR + '/') if DATADIR != "": add_config_h ("CONF_DATADIR", '"' + DATADIR + '"') add_config_mak ("CONF_DATADIR", DATADIR + '/') if LIBDIR != "": add_config_h ("CONF_LIBDIR", '"' + LIBDIR + '"') add_config_mak ("CONF_LIBDIR", LIBDIR + '/') if INCLUDEDIR != "": add_config_h ("CONF_INCLUDEDIR", '"' + INCLUDEDIR + '"') add_config_mak ("CONF_INCLUDEDIR", INCLUDEDIR + '/') if DOCDIR != "": add_config_h ("CONF_DOCDIR", '"' + DOCDIR + '"') add_config_mak ("CONF_DOCDIR", DOCDIR + '/') if LIBEXECDIR != "": add_config_h ("CONF_LIBEXECDIR", '"' + LIBEXECDIR + '"') add_config_mak ("CONF_LIBEXECDIR", LIBEXECDIR + '/') if SHAREDLIBS: add_config_h ("CONF_SHAREDLIBS", "1") add_config_mak ("SHAREDLIBS", "1") else: add_config_h ("CONF_SHAREDLIBS", "0") add_config_mak ("SHAREDLIBS", "")
def start (): """Start the autoconfiguring process. This includes searching the environment for variables, parsing the command line, detecting host/target and compiler and setting the base variables. """ global HOST, TARGET, EXE, TOOLKIT, COMPILER global PREFIX, BINDIR, LIBDIR, SYSCONFDIR, DATADIR, DOCDIR global INCLUDEDIR, LIBEXECDIR, SHAREDLIBS detect_platform () # Read environment variables first for e in ENVARS: globals () [e [0]] = os.getenv (e [0], e [1]) # Parse command-line skip_opt = False for optidx in range (1, len (sys.argv)): if skip_opt: skip_opt = False continue opt = sys.argv [optidx] optarg = None opt_ok = False if opt [:2] == "--": opt = opt [2:] opt_short = False for o in OPTIONS: if o [1] and o [1] == opt [:len (o [1])]: optarg = opt [len (o [1]):] if optarg [:1] == '=' or len (opt) == len (o [1]): opt_ok = True optarg = optarg [1:] break elif opt [:1] == "-": opt = opt [1:] opt_short = True for o in OPTIONS: if o [0] and o [0] == opt: opt_ok = True break if not opt_ok: print "Unknown command-line option: '" + opt + "'" sys.exit (1) # Check if option needs argument if o [2] and opt_short: if optidx >= len (sys.argv): print "Option '" + opt + "' needs an argument" sys.exit (1) skip_opt = True optarg = sys.argv [optidx + 1] if not o [2] and optarg: print "Option '" + opt + "' does not accept an argument" sys.exit (1) exec o [3] # Print the host and target platforms print "Compiling on host " + ".".join (HOST) + " for target " + \ ".".join (TARGET [:2]) + " (tune for " + TARGET [2] + ")" # Now set target-specific defaults if TARGET [0] == "windows": EXE = ".exe" else: EXE = "" add_config_h ("CONF_PACKAGE", '"' + PROJ + '"') add_config_mak ("CONF_PACKAGE", PROJ) add_config_h ("CONF_VERSION", '"' + VERSION + '"') add_config_mak ("CONF_VERSION", VERSION) add_config_h ("PLATFORM_" + TARGET [0].upper ()) add_config_h ("ARCH_" + TARGET [1].upper ()) add_config_h ("TUNE_" + TARGET [2].upper ()) add_config_mak ("HOST", HOST [0]) add_config_mak ("TARGET", TARGET [0]) add_config_mak ("ARCH", TARGET [1]) add_config_mak ("TUNE", TARGET [2]) if BINDIR is None: BINDIR = PREFIX + "/bin" if SYSCONFDIR is None: SYSCONFDIR = PREFIX + "/etc/" + PROJ if DATADIR is None: DATADIR = PREFIX + "/share/" + PROJ if DOCDIR is None: DOCDIR = PREFIX + "/share/doc/" + PROJ + "-" + VERSION # http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64 if LIBDIR is None: if TARGET [1] [-2:] == "64": LIBDIR = PREFIX + "/lib64" # Debian doesn't follow LFS in this regard try: os.stat (LIBDIR) except: LIBDIR = PREFIX + "/lib" else: LIBDIR = PREFIX + "/lib" if INCLUDEDIR is None: INCLUDEDIR = PREFIX + "/include" if LIBEXECDIR is None: LIBEXECDIR = PREFIX + "/libexec/" + PROJ # Instantiate the compiler-dependent class TOOLKIT = COMPILERS.get (COMPILER); if not TOOLKIT: print "Unsupported compiler: " + COMPILER sys.exit (1) TOOLKIT = TOOLKIT () TOOLKIT.startup () add_config_h ("CONF_COMPILER_" + COMPILER) if PREFIX != "": add_config_h ("CONF_PREFIX", '"' + PREFIX + '"') add_config_mak ("CONF_PREFIX", PREFIX + '/') if BINDIR != "": add_config_h ("CONF_BINDIR", '"' + BINDIR + '"') add_config_mak ("CONF_BINDIR", BINDIR + '/') if SYSCONFDIR != "": add_config_h ("CONF_SYSCONFDIR", '"' + SYSCONFDIR + '"') add_config_mak ("CONF_SYSCONFDIR", SYSCONFDIR + '/') if DATADIR != "": add_config_h ("CONF_DATADIR", '"' + DATADIR + '"') add_config_mak ("CONF_DATADIR", DATADIR + '/') if LIBDIR != "": add_config_h ("CONF_LIBDIR", '"' + LIBDIR + '"') add_config_mak ("CONF_LIBDIR", LIBDIR + '/') if INCLUDEDIR != "": add_config_h ("CONF_INCLUDEDIR", '"' + INCLUDEDIR + '"') add_config_mak ("CONF_INCLUDEDIR", INCLUDEDIR + '/') if DOCDIR != "": add_config_h ("CONF_DOCDIR", '"' + DOCDIR + '"') add_config_mak ("CONF_DOCDIR", DOCDIR + '/') if LIBEXECDIR != "": add_config_h ("CONF_LIBEXECDIR", '"' + LIBEXECDIR + '"') add_config_mak ("CONF_LIBEXECDIR", LIBEXECDIR + '/') if SHAREDLIBS: add_config_h ("CONF_SHAREDLIBS", "1") add_config_mak ("SHAREDLIBS", "1") else: add_config_h ("CONF_SHAREDLIBS", "0") add_config_mak ("SHAREDLIBS", "")
479,185
def detect_platform (): global HOST, TARGET, DEVNULL if sys.platform [:3] == "win": HOST = ["windows"] TARGET = ["windows"] DEVNULL = "nul" elif sys.platform [:6] == "darwin": HOST = ["mac"] TARGET = ["mac"] DEVNULL = "/dev/null" else: # Default to POSIX HOST = ["posix"] TARGET = ["posix"] DEVNULL = "/dev/null" arch = platform.machine () # Python 2.5 on windows returns empty string here if (arch == "") or \ (len (arch) >= 4 and arch [0] == "i" and arch [2:4] == "86" and arch [4:] == ""): arch = "x86" HOST.append (arch) TARGET.append (arch) cpu = platform.processor ().replace ("-", "_") TARGET.append (cpu) # HOST contains ["platform", "arch"] # TARGET contains ["platform", "arch", "tune"]
def detect_platform (): global HOST, TARGET, DEVNULL if sys.platform [:3] == "win": HOST = ["windows"] TARGET = ["windows"] DEVNULL = "nul" elif sys.platform [:6] == "darwin": HOST = ["mac"] TARGET = ["mac"] DEVNULL = "/dev/null" else: # Default to POSIX HOST = ["posix"] TARGET = ["posix"] DEVNULL = "/dev/null" arch = platform.machine () # Python 2.5 on windows returns empty string here if (arch == "") or \ (len (arch) >= 4 and arch [0] == "i" and arch [2:4] == "86" and arch [4:] == ""): arch = "x86" HOST.append (arch) TARGET.append (arch) cpu = platform.processor () if (not cpu) or (len (cpu) == 0): cpu = platform.machine () TARGET.append (cpu.replace ("-", "_")) # HOST contains ["platform", "arch"] # TARGET contains ["platform", "arch", "tune"]
479,186
def add_config_h (macro, val = "1"): global CONFIG_H macro = macro.strip () CONFIG_H [macro] = val.strip () _CONFIG_H.append (macro)
def add_config_h (macro, val = "1"): """Add a macro definition to config.h file. The contents of config.h is accumulated during configure run in the tibs.CONFIG_H variable and finally is written out with a tibs.update_file() call. :Parameters: `macro` : str The name of the macro to define. Usually upper-case. `val` : str The value of the macro. If not specified, defaults to "1". """ global CONFIG_H, _CONFIG_H macro = macro.strip () CONFIG_H [macro] = val.strip () _CONFIG_H.append (macro)
479,187
def add_config_mak (macro, val = "1"): global CONFIG_MAK macro = macro.strip () CONFIG_MAK [macro] = val.strip () _CONFIG_MAK.append (macro)
def add_config_mak (macro, val = "1"): """Add a macro definition to config.mak file. The contents of config.mak is accumulated during configure run in the tibs.CONFIG_MAK variable and finally is written out with a tibs.update_file() call. :Parameters: `macro` : str The name of the macro to define. Usually upper-case. `val` : str The value of the macro. If not specified, defaults to "1". """ global CONFIG_MAK, _CONFIG_MAK macro = macro.strip () CONFIG_MAK [macro] = val.strip () _CONFIG_MAK.append (macro)
479,188
def check_program (name, prog, ver_regex, req_version, failifnot = False): check_started ("Checking for " + name + " >= " + req_version) rc = False version = None try: fd = os.popen (prog + " 2>&1") line = fd.readline ().strip () fd.close () if VERBOSE: print "\n# '" + prog + "' returned '" + line + "'" m = re.match (ver_regex, line) if not m: raise version = m.group (1) if not compare_version (version, req_version): raise check_finished (version + ", OK") rc = True except: if version: check_finished (version + " < " + req_version + ", FAILED") else: check_finished ("FAILED") if not rc and failifnot: print "\n" + name + " version " + req_version + " and above is required to build this project" sys.exit (1) return rc
def check_program (name, prog, ver_regex, req_version, failifnot = False): check_started ("Checking for " + name + " >= " + req_version) rc = False version = None try: fd = os.popen (prog + " 2>&1") lines = fd.readlines () fd.close () if VERBOSE: print "\n# '" + prog + "' returned '" + line + "'" m = re.match (ver_regex, line) if not m: raise version = m.group (1) if not compare_version (version, req_version): raise check_finished (version + ", OK") rc = True except: if version: check_finished (version + " < " + req_version + ", FAILED") else: check_finished ("FAILED") if not rc and failifnot: print "\n" + name + " version " + req_version + " and above is required to build this project" sys.exit (1) return rc
479,189
def check_program (name, prog, ver_regex, req_version, failifnot = False): check_started ("Checking for " + name + " >= " + req_version) rc = False version = None try: fd = os.popen (prog + " 2>&1") line = fd.readline ().strip () fd.close () if VERBOSE: print "\n# '" + prog + "' returned '" + line + "'" m = re.match (ver_regex, line) if not m: raise version = m.group (1) if not compare_version (version, req_version): raise check_finished (version + ", OK") rc = True except: if version: check_finished (version + " < " + req_version + ", FAILED") else: check_finished ("FAILED") if not rc and failifnot: print "\n" + name + " version " + req_version + " and above is required to build this project" sys.exit (1) return rc
def check_program (name, prog, ver_regex, req_version, failifnot = False): check_started ("Checking for " + name + " >= " + req_version) rc = False version = None try: fd = os.popen (prog + " 2>&1") line = fd.readline ().strip () fd.close () if VERBOSE: print "\n# '" + prog + "' returned '" + line + "'" m = re.match (ver_regex, line) if not m: raise version = m.group (1) if not compare_version (version, req_version): raise check_finished (version + ", OK") rc = True except: if version: check_finished (version + " < " + req_version + ", FAILED") else: check_finished ("FAILED") if not rc and failifnot: print "\n" + name + " version " + req_version + " and above is required to build this project" sys.exit (1) return rc
479,190
def check_program (name, prog, ver_regex, req_version, failifnot = False): check_started ("Checking for " + name + " >= " + req_version) rc = False version = None try: fd = os.popen (prog + " 2>&1") line = fd.readline ().strip () fd.close () if VERBOSE: print "\n# '" + prog + "' returned '" + line + "'" m = re.match (ver_regex, line) if not m: raise version = m.group (1) if not compare_version (version, req_version): raise check_finished (version + ", OK") rc = True except: if version: check_finished (version + " < " + req_version + ", FAILED") else: check_finished ("FAILED") if not rc and failifnot: print "\n" + name + " version " + req_version + " and above is required to build this project" sys.exit (1) return rc
def check_program (name, prog, ver_regex, req_version, failifnot = False): check_started ("Checking for " + name + " >= " + req_version) rc = False version = None try: fd = os.popen (prog + " 2>&1") line = fd.readline ().strip () fd.close () if VERBOSE: print "\n# '" + prog + "' returned '" + line + "'" m = re.match (ver_regex, line) if not m: raise check_finished (version + ", OK") rc = True except: if version: check_finished (version + " < " + req_version + ", FAILED") else: check_finished ("FAILED") if not rc and failifnot: print "\n" + name + " version " + req_version + " and above is required to build this project" sys.exit (1) return rc
479,191
def pkgconfig (prog, args, lib = None): # Check if target overrides this library tmp_lib = lib if not tmp_lib: tmp_lib = prog.replace ("_config", "").replace ("-config", "") # Allow user to override any pkgconfig data with environment env_var = "PKGCONFIG_" + tmp_lib + "_" + args env_val = os.getenv (env_var, None) if env_val: if args == "exists": return True return env_val # Check if there's a static library configuration defined if tmp_lib in PKGCONFIG: if args == "exists": return True pkg = PKGCONFIG [tmp_lib] if args in pkg: return pkg [args] return "" # Do not use pkg-config if cross-compiling if HOST [:1] != TARGET [:1]: abort_configure (
def pkgconfig (prog, args, lib = None): # Check if target overrides this library tmp_lib = lib if not tmp_lib: tmp_lib = prog.replace ("_config", "").replace ("-config", "") # Allow user to override any pkgconfig data with environment env_var = "PKGCONFIG_" + tmp_lib + "_" + args env_val = os.getenv (env_var, None) if env_val: if args == "exists": return True return env_val # Check if there's a static library configuration defined if tmp_lib in PKGCONFIG: if args == "exists": return True pkg = PKGCONFIG [tmp_lib] if args in pkg: return pkg [args] return "" # Do not use pkg-config if cross-compiling if HOST [:1] != TARGET [:1]: abort_configure (
479,192
def substmacros (infile, outfile = None, macros = None): if not outfile: if infile.endswith (".in"): outfile = infile [:-3] else: abort_configure (
def substmacros (infile, outfile = None, macros = None): if not outfile: if infile.endswith (".in"): outfile = infile [:-3] else: abort_configure (
479,193
def _read_member_header(self): """Fills self._chlen and self._chunks by the read header data. """ header = _read_gzip_header(self._fileobj) offset = self._fileobj.tell() if "RA" not in header["extra_field"]: raise IOError("Not an idzip file: %r" % self.name)
def _read_member_header(self): """Fills self._chlen and self._chunks by the read header data. """ header = _read_gzip_header(self._fileobj) offset = self._fileobj.tell() if "RA" not in header["extra_field"]: raise IOError("Not an idzip file: %r" % self.name)
479,194
def _readchunk(self, chunk_index): """Reads the specified chunk or throws EOFError. """ while chunk_index >= len(self._chunks): self._reach_member_end() _read_member_header()
def _readchunk(self, chunk_index): """Reads the specified chunk or throws EOFError. """ while chunk_index >= len(self._chunks): self._reach_member_end() _read_member_header()
479,195
def _reach_member_end(self): """Seeks the _fileobj at the end of the last known member. """ offset, comp_len = self._chunks[-1] self._fileobj.seek(offset + comp_len) # The zlib stream could end with an empty block. deobj = zlib.decompressobj(-zlib.MAX_WBITS) extra = "" while deobj.unused_data == "" and not extra: extra += deobj.decompress(self.fileobj.read(3))
def _reach_member_end(self): """Seeks the _fileobj at the end of the last known member. """ offset, comp_len = self._chunks[-1] self._fileobj.seek(offset + comp_len) # The zlib stream could end with an empty block. deobj = zlib.decompressobj(-zlib.MAX_WBITS) extra = "" while deobj.unused_data == "" and not extra: extra += deobj.decompress(self.fileobj.read(3))
479,196
def _compress_member(input, in_size, output, basename, mtime): comp_lenghts_pos = _prepare_header(output, in_size, basename, mtime) comp_lengths = _compress_data(input, in_size, output) end_pos = output.tell() output.seek(comp_lenghts_pos) for comp_len in comp_lengths: _write16(output, comp_len) output.seek(end_pos)
def _compress_member(input, in_size, output, basename, mtime): comp_lengths_pos = _prepare_header(output, in_size, basename, mtime) comp_lengths = _compress_data(input, in_size, output) end_pos = output.tell() output.seek(comp_lenghts_pos) for comp_len in comp_lengths: _write16(output, comp_len) output.seek(end_pos)
479,197
def _compress_member(input, in_size, output, basename, mtime): comp_lenghts_pos = _prepare_header(output, in_size, basename, mtime) comp_lengths = _compress_data(input, in_size, output) end_pos = output.tell() output.seek(comp_lenghts_pos) for comp_len in comp_lengths: _write16(output, comp_len) output.seek(end_pos)
def _compress_member(input, in_size, output, basename, mtime): comp_lenghts_pos = _prepare_header(output, in_size, basename, mtime) comp_lengths = _compress_data(input, in_size, output) end_pos = output.tell() output.seek(comp_lengths_pos) for comp_len in comp_lengths: _write16(output, comp_len) output.seek(end_pos)
479,198
def _prepare_header(output, in_size, basename, mtime): """Returns a prepared gzip header StringIO. The gzip header is defined in RFC 1952. """ output.write("\x1f\x8b\x08") # Gzip-deflate identification flags = FEXTRA if basename: flags |= FNAME output.write(chr(flags)) # The mtime will be undefined if it does not fit. if mtime > 0xffffffffL: mtime = 0 _write32(output, mtime) deflate_flags = "\0" if COMPRESSION_LEVEL == zlib.Z_BEST_COMPRESSION: deflate_flags = "\x02" # slowest compression algorithm output.write(deflate_flags) output.write(chr(OS_CODE_UNIX)) comp_lenghts_pos = _write_extra_fields(output, in_size) if basename: output.write(basename + '\0') # original basename return comp_lenghts_pos
def _prepare_header(output, in_size, basename, mtime): """Returns a prepared gzip header StringIO. The gzip header is defined in RFC 1952. """ output.write("\x1f\x8b\x08") # Gzip-deflate identification flags = FEXTRA if basename: flags |= FNAME output.write(chr(flags)) # The mtime will be undefined if it does not fit. if mtime > 0xffffffffL: mtime = 0 _write32(output, mtime) deflate_flags = "\0" if COMPRESSION_LEVEL == zlib.Z_BEST_COMPRESSION: deflate_flags = "\x02" # slowest compression algorithm output.write(deflate_flags) output.write(chr(OS_CODE_UNIX)) comp_lengths_pos = _write_extra_fields(output, in_size) if basename: output.write(basename + '\0') # original basename return comp_lenghts_pos
479,199