rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
column = gtk.TreeViewColumn(_(name), text_renderer, text=column_number)
column = gtk.TreeViewColumn(name, renderer, text=column_number)
def add_text_column(name): column_number = len(self.subscription_view.get_columns()) column = gtk.TreeViewColumn(_(name), text_renderer, text=column_number)
add_text_column("Subscription") add_text_column("Installed Products") add_text_column("Contract") add_text_column("Start Date") add_text_column("Expiration Date") add_text_column("Available Renewals")
add_column(_("Subscription")) add_column(_("Installed Products")) add_column(_("Contract")) add_column(_("Start Date")) add_column(_("Expiration Date")) add_column(_("Available Renewals"))
def add_text_column(name): column_number = len(self.subscription_view.get_columns()) column = gtk.TreeViewColumn(_(name), text_renderer, text=column_number)
renew_renderer = gtk.CellRendererToggle() renew_renderer.set_property('activatable', True) renew_renderer.connect('toggled', self.on_renew_click, None) add_column(_("Actions"), renderer=renew_renderer) self.update_subscriptions() def on_renew_click(self, cell, path, model): pass def update_subscriptions(self): if not managergui.consumer: return pools = managergui.UEP.getPoolsList(managergui.consumer['uuid']) for pool in pools: subscription = [] subscription.append(pool['productName']) subscription.append('%s/%s' % (pool['consumed'], pool['quantity'])) subscription.append('Contract...') subscription.append(pool['startDate']) subscription.append(pool['endDate']) subscription.append('?') subscription.append(True) self.subscription_store.append(subscription)
def add_text_column(name): column_number = len(self.subscription_view.get_columns()) column = gtk.TreeViewColumn(_(name), text_renderer, text=column_number)
if prod['productId'] not in compatible_pids:
if prod['productId'] not in compatible_pids + matched_pids:
def __init__(self): global UEP self.selected = {} self.addxml = gtk.glade.XML(gladexml, "dialog_add", domain="subscription-manager") self.csstatus = self.addxml.get_widget("select_status") self.total = 0 self.consumer = consumer available_ent = 0 if consumer.has_key('uuid'): self.availableList = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, \ gobject.TYPE_STRING, gobject.TYPE_STRING) self.matchedList = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, \ gobject.TYPE_STRING, gobject.TYPE_STRING) self.compatList = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, \ gobject.TYPE_STRING, gobject.TYPE_STRING)
"Accept-Language": locale.getdefaultlocale()[0]}
"Accept-Language": locale.getdefaultlocale()[0].lower().replace('_', '-')}
def __init__(self, host, port, ssl_port, apihandler, cert_file=None, key_file=None,): self.host = host self.port = port self.ssl_port = ssl_port self.apihandler = apihandler self.headers = {"Content-type":"application/json", "Accept": "application/json", "Accept-Language": locale.getdefaultlocale()[0]} self.cert_file = cert_file self.key_file = key_file
print self.add_subscription_screen
def onUnsubscribeAction(self, button): global UEP if not self.psubs_selected: return log.info("Product %s selected for unsubscribe" % self.pname_selected) dlg = messageWindow.YesNoDialog(constants.CONFIRM_UNSUBSCRIBE % xml.sax.saxutils.escape(self.pname_selected), self.mainWin) if not dlg.getrc(): return
updated_pool = UEP.getPool(ent_ret[0]['pool']['id']) updated_count = str(int(updated_pool['quantity']) - int(updated_pool['consumed']))
def onSubscribeAction(self, button): slabel = rhsm_xml.get_widget("available_subscriptions_label") subscribed_count = 0 pwin = progress.Progress() pwin.setLabel(_("Performing Subscribe. Please wait.")) busted_subs = [] count = 0
my_model.set_value(state[2], 2, updated_count)
def onSubscribeAction(self, button): slabel = rhsm_xml.get_widget("available_subscriptions_label") subscribed_count = 0 pwin = progress.Progress() pwin.setLabel(_("Performing Subscribe. Please wait.")) busted_subs = [] count = 0
port = cfg['port'] ssl_port = cfg['ssl_port']
ssl_port = cfg['port']
def __init__(self): cfg = initConfig() host = cfg['hostname'] or "localhost" port = cfg['port'] ssl_port = cfg['ssl_port'] cert_file = ConsumerIdentity.certpath() key_file = ConsumerIdentity.keypath() UEPConnection.__init__(self, host, port, ssl_port, cert_file=cert_file, key_file=key_file) self.uuid = self.consumerId()
UEPConnection.__init__(self, host, port, ssl_port, cert_file=cert_file, key_file=key_file)
UEPConnection.__init__(self, host, ssl_port, cert_file=cert_file, key_file=key_file)
def __init__(self): cfg = initConfig() host = cfg['hostname'] or "localhost" port = cfg['port'] ssl_port = cfg['ssl_port'] cert_file = ConsumerIdentity.certpath() key_file = ConsumerIdentity.keypath() UEPConnection.__init__(self, host, port, ssl_port, cert_file=cert_file, key_file=key_file) self.uuid = self.consumerId()
pools = model.get_value(tree_iter, MERGED_POOLS_INDEX)
pools = model.get_value(tree_iter, self.subs_store['merged_pools'])
def subscribe_button_clicked(self, button): model, tree_iter = self.subs_treeview.get_selection().get_selected() pools = model.get_value(tree_iter, MERGED_POOLS_INDEX) # Decide if we need to show the contract selection dialog or not. # if there's just one pool, shortcut right to the callback that the # dialog would have run. if len(pools.pools) == 1: self._contract_selected(pools.pools[1])
print order.getStart()
def validRange(self): """ Get the I{valid} date range.
subscription.append(float(len(installed)) / len(products))
subscription.append(self._calculate_percentage(installed, products))
def update_subscriptions(self): entcerts = EntitlementDirectory().list()
print "writing to ", self.config_file
def save(self, config_file=None): fo = open(self.config_file, "wb") print "writing to ", self.config_file self.write(fo)
add_subscription_screen = None
def fetch_certificates(): # Force fetch all certs try: certlib.update() except Exception, e: log.error("Certificate sync failed") log.error(e) return False return True
def show_add_subscription_screen(): global add_subscription_screen
def show_regtoken_screen(): global regtoken_screen if regtoken_screen: regtoken_screen.show() else: regtoken_screen = RegistrationTokenScreen()
if add_subscription_screen: add_subscription_screen.show() else: add_subscription_screen = AddSubscriptionScreen()
def show_add_subscription_screen(): global add_subscription_screen if add_subscription_screen: add_subscription_screen.show() else: add_subscription_screen = AddSubscriptionScreen()
self.add_subscription_screen = None
def create_gui(self): global UEP
print "addSubButtonAction"
print 'ManageSubscriptionPage.addSubButtonAction() -> show_add_subscription_screen()'
def addSubButtonAction(self, button): print "addSubButtonAction" if consumer.has_key('uuid'): show_add_subscription_screen() else: show_import_certificate_screen()
show_add_subscription_screen()
self.show_add_subscription_screen()
def addSubButtonAction(self, button): print "addSubButtonAction" if consumer.has_key('uuid'): show_add_subscription_screen() else: show_import_certificate_screen()
self.gui_reload()
def addSubButtonAction(self, button): print "addSubButtonAction" if consumer.has_key('uuid'): show_add_subscription_screen() else: show_import_certificate_screen()
print "updateProductDialog"
print "[%s] updateProductDialog called" % time.time()
def updateProductDialog(self): print "updateProductDialog" self.warn_count = 0 self.productList.clear() for product in managerlib.getInstalledProductStatus(): markup_status = product[1] if product[1] in ["Expired", "Not Subscribed", "Not Installed"]: self.warn_count += 1 markup_status = '<span foreground="red"><b>%s</b></span>' % product[1] self.status_icon = self.tv_products.render_icon(self.state_icon_map[product[1]], size=gtk.ICON_SIZE_MENU) self.productList.append((self.status_icon, product[0], product[3], markup_status, product[2], product[4])) self.tv_products.set_model(self.productList)
print "gui_reload"
def gui_reload(self, widget=None): print "gui_reload" print logutil.trace_me_more() self.setRegistrationStatus() self.updateProductDialog()
print "[%s] in AddSubscriptinScreen.__init__" % time.time()
def __init__(self): global UEP self.selected = {} self.csstatus = rhsm_xml.get_widget("select_status") self.total = 0 self.consumer = consumer self.available_ent = 0
self.addWin.connect("hide", self.cancel)
def __init__(self): global UEP self.selected = {} self.csstatus = rhsm_xml.get_widget("select_status") self.total = 0 self.consumer = consumer self.available_ent = 0
self.addWin.run()
def __init__(self): global UEP self.selected = {} self.csstatus = rhsm_xml.get_widget("select_status") self.total = 0 self.consumer = consumer self.available_ent = 0
print 'subscribe window hiding'
def cancel(self, button): self.addWin.hide()
'fact2': 'two' }
'fact2': 'two', 'system': '', 'system.uuid': 'MOCKUUID'}
def setUp(self):
def check_facts(fact): found_facts[fact[0]] = fact[1]
def check_facts(parent, facts): found_facts[facts[0]] = facts[1]
def check_facts(fact): found_facts[fact[0]] = fact[1]
self.write(facts)
self.write(self.facts)
def get_facts(self): if self.facts: # see bz #627707 # there is a little bit of a race between when we load the facts, and when # we decide to save them, so delete facts out from under a Fact object means # it wasn't detecting it missing in that case and not writing a new one self.write(facts) return self.facts self.facts = self.find_facts() return self.facts
self.conn.headers['Authorization'] = basic return self.conn.headers
self.basic_auth_conn.headers['Authorization'] = basic return self.basic_auth_conn.headers
def __authenticate(self, username, password): encoded = base64.encodestring(':'.join((username,password))) basic = 'Basic %s' % encoded[:-1] self.conn.headers['Authorization'] = basic return self.conn.headers
return self.conn.request_post('/consumers/', params)
return self.basic_auth_conn.request_post('/consumers/', params)
def registerConsumer(self, username, password, name="unknown", type="system", facts={}): """ Creates a consumer on candlepin server """ params = { "type": type, "name": name, "facts": facts } self.__authenticate(username, password) return self.conn.request_post('/consumers/', params)
config_insecure = config.get('server', 'insecure')
config_insecure = int(config.get('server', 'insecure'))
def __init__(self, host=config.get('server', 'hostname', 'localhost'), ssl_port=int(config.get('server', 'port', 8443)), handler=config.get('server', 'prefix', '/candlepin'), cert_file=None, key_file=None):
return date.today()
return datetime.now(certificate.GMT())
def get_date(sub): return sub.validRange().end()
def update(self): repod = RepoFile() repod.read() valid = set() updates = 0 bundles = self.bundles() for cont in self.content(bundles): name = cont.id valid.add(name) existing = repod[name] if existing is None: updates += 1 repod[name] = cont continue updates += existing.update(cont) delete = [] for name in repod.section: if name not in valid: delete.append(name) for name in delete: updates += 1 del repod.section[name] repod.write() return updates
requires_api_version = '2.3' plugin_type = (TYPE_CORE, TYPE_INTERACTIVE)
def update(self): repod = RepoFile() repod.read() valid = set() updates = 0 bundles = self.bundles() for cont in self.content(bundles): name = cont.id valid.add(name) existing = repod[name] if existing is None: updates += 1 repod[name] = cont continue updates += existing.update(cont) delete = [] for name in repod.section: if name not in valid: delete.append(name) for name in delete: updates += 1 del repod.section[name] repod.write() return updates
def bundles(self): bundles = [] for b in CertDirectory().bundles(): bundles.append(b) return bundles def content(self, bundles): unique = set() bundles.sort() bundles.reverse() for bundle in bundles: for repo in bundle.content(): unique.add(repo) return unique class Reader: def __init__(self): self.section = {} self.section[None] = self.newsection(None) def read(self, path): f = open(path) section = self.section[None] for line in f.readlines(): line = line.strip() if line.startswith('[') and line.endswith(']'): name = line[1:-1].strip() section = self.newsection(name) self.section[name] = section continue if line.startswith(' continue part = line.split('=', 1) if len(part) != 2: continue name = part[0].strip() value = part[1].strip() section[name] = value if len(self.section) > 1: del self.section[None] f.close() def newsection(self, name): return {} def __getitem__(self, name): return self.section.get(name) class Configuration(Reader): PATH = '/etc/subscription-manager/rhsm.conf' def __init__(self): self.read(self.PATH) def __getitem__(self, name): return self.section[None].get(name) class Directory: def __init__(self, path): self.path = path def list(self): entries = [] for fn in os.listdir(self.path): p = (self.path, fn) entries.append(p) return entries def listdirs(self): dir = [] for p,fn in self.list(): path = os.path.join(p, fn) if os.path.isdir(path): dir.append(Directory(path)) return dir def create(self): if not os.path.exists(self.path): os.makedirs(self.path) def delete(self): self.clean() os.rmdir(self.path) def clean(self): for x in os.listdir(self.path): path = os.path.join(self.path, x) if os.path.isdir(path): d = Directory(path) d.delete() else: os.remove(path) class Repo(dict): KEYS = ( ('name', 0, None), ('baseurl', 1, None), ('enabled', 0, '1'), ('gpgcheck', 0, '0'), ('gpgkey', 1, None), ('sslverify', 0, '1'), ('sslclientkey', 1, None), ('sslclientcert', 1, None), ) def __init__(self, id): self.id = id for k,m,d in self.KEYS: self[k] = d def update(self, other): count = 0 for k,m,d in self.KEYS: v = other.get(k) if m: if v is None: continue if self[k] == v: continue self[k] = v count += 1 return count def __str__(self): s = [] s.append('[%s]' % self.id) for k,m,d in self.KEYS: v = self.get(k) if v is None: continue s.append('%s=%s' % (k, v)) return '\n'.join(s) def __repr__(self): s = [] for k,m,d in self.KEYS: v = self.get(k) s.append('%s=%s' % (k, v)) return '\n'.join(s) def __eq__(self, other): return ( self.id == other.id ) def __hash__(self): return hash(self.id) class RepoFile(Reader): PATH = '/etc/yum.repos.d/' def __init__(self, name='redhat.repo'): Reader.__init__(self) self.path = os.path.join(self.PATH, name) self.create() def newsection(self, name): return Repo(name) def read(self): Reader.read(self, self.path) def write(self): f = open(self.path, "w") f.write(str(self)) f.close() def create(self): if not os.path.exists(self.path): f = open(self.path, 'w') f.close() def __setitem__(self, name, value): self.section[name] = value def __str__(self): s = [] s.append(' s.append(' s.append(' s.append(' for name, repo in self.section.items(): s.append(str(repo)) s.append('') return '\n'.join(s) class Bundle: def __init__(self, key, cert): self.key = key self.cert = cert def content(self): cont = [] for ent in self.cert.getEntitlements(): id = ent.getName() repo = Repo(id) repo['name'] = ent.getDescription() repo['baseurl'] = ent.getUrl() repo['sslclientkey'] = self.key.path repo['sslclientcert'] = self.cert.path cont.append(repo) return cont def __cmp__(self, other): range = self.cert.validRange() exp1 = range.end() range = other.cert.validRange() exp2 = range.end() if exp1 < exp2: return -1 if exp1 > exp2: return 1 return 0 class CertDirectory(Directory): ROOT = '/etc/pki/redhat/entitlement' def __init__(self): Directory.__init__(self, self.ROOT) self.create() def bundles(self): bundles = [] for dir in Directory.listdirs(self): d = {} for p,fn in dir.list(): if fn == 'key.pem': d[1] = os.path.join(p, fn) continue if fn == 'cert.pem': d[2] = os.path.join(p, fn) if len(d) == 2: key = Key(d[1]) cert = ProductCertificate(d[2]) if not cert.valid(): continue b = Bundle(key, cert) bundles.append(b) return bundles def main(): print 'Updating Red Hat repository' repolib = RepoLib(None) updates = repolib.update() print '%d updates required' % updates print 'done' if __name__ == '__main__': main()
def config_hook(conduit): try: rl = RepoLib() rl.update() except Exception, ex: conduit.error(0, str(ex))
def bundles(self): bundles = [] for b in CertDirectory().bundles(): bundles.append(b) return bundles
dic = { "on_button_close_clicked" : gtk.main_quit,
dic = { "on_update_close_clicked" : gtk.main_quit,
def create_gui(self): global UEP
AddSubscriptionScreen()
show_add_subscription_screen()
def addSubButtonAction(self, button): AddSubscriptionScreen() self.gui_reload()
dic = { "on_close_clicked" : self.cancel,
dic = { "on_register_close_clicked" : self.cancel,
def __init__(self): create_and_set_basic_connection() dic = { "on_close_clicked" : self.cancel, "on_register_button_clicked" : self.onRegisterAction, } rhsm_xml.signal_autoconnect(dic) self.registerWin = rhsm_xml.get_widget("register_dialog") self.registerWin.connect("hide", self.cancel) self.initializeConsumerName()
dic = { "on_close_clicked" : self.finish,
dic = { "on_register_token_close_clicked" : self.finish,
def __init__(self): dic = { "on_close_clicked" : self.finish, "on_change_account_button" : self.reRegisterAction, "on_facts_update_button_clicked" : self.factsUpdateAction, "on_submit_button_clicked" : self.submitToken, "on_unregister_button_click" : self.unregisterAction} self.setAccountMsg() rhsm_xml.signal_autoconnect(dic) self.regtokenWin = rhsm_xml.get_widget("register_token_dialog") self.regtokenWin.connect("hide", self.finish) self.regtokenWin.run()
dic = { "on_close_clicked" : self.cancel,
dic = { "on_add_subscribe_close_clicked" : self.cancel,
def __init__(self): global UEP self.selected = {} self.csstatus = rhsm_xml.get_widget("select_status") self.total = 0 self.consumer = consumer available_ent = 0 if consumer.has_key('uuid'): self.availableList = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, \ gobject.TYPE_STRING, gobject.TYPE_STRING) self.matchedList = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, \ gobject.TYPE_STRING, gobject.TYPE_STRING) self.compatList = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, \ gobject.TYPE_STRING, gobject.TYPE_STRING)
self.addWin.destroy()
def finish(self): self.addWin.hide() self.addWin.destroy() gtk.main_iteration()
self.addWin.destroy() gtk.main_iteration()
self.addWin.hide() def show(self): self.addWin.present()
def cancel(self, button): self.addWin.destroy() gtk.main_iteration()
print "gh 2000"
def onSubscribeAction(self, button): slabel = rhsm_xml.get_widget("label_status1") #consumer = get_consumer() subscribed_count = 0 #my_model = self.tv_products.get_model() #my_model = self.other_tv.get_model() my_model = self.match_tv.get_model() pwin = progress.Progress() pwin.setLabel(_("Performing Subscribe. Please wait.")) busted_subs = [] count = 0 pwin.setProgress(count, len(self.selected.items()))
print self.total
def col_matched_selected(self, cell, path, model): items, iter = self.match_tv.get_selection().get_selected() model[path][0] = not model[path][0] self.model = model state = model.get_value(iter, 0) self.selected[model.get_value(iter, 4)] = (state, model.get_value(iter, 1), iter) if state: self.total += 1 else: self.total -= 1 if not self.total: self.csstatus.hide() return self.csstatus.show() self.csstatus.set_label(constants.SELECT_STATUS % self.total)
dic = { "on_close_clicked" : self.cancel,
dic = { "on_update_subscriptions_close_clicked" : self.cancel,
def __init__(self, product_selection): global UEP
dic = { "on_close_import" : self.cancel,
dic = { "on_close_import_clicked" : self.cancel,
def __init__(self): self.add_vbox = rhsm_xml.get_widget("import_vbox")
errorWindow(constants.REGISTER_ERROR)
errorWindow(constants.REGISTER_ERROR % e)
def onRegisterAction(self, button): self.uname = self.registerxml.get_widget("account_login") self.passwd = self.registerxml.get_widget("account_password")
self.cp.bindByProduct(self.consumer['uuid'], phash)
self.cp.bindByProduct(consumer['uuid'], phash)
def _do_command(self): """ Executes the command. """ self._validate_options()
handle_exception(_("Error: Unable to Re-register the system", e))
handle_exception(_("Error: Unable to Re-register the system"), e)
def _do_command(self):
if not ConsumerIdentity.exists() and not (self.options.username and self.options.password): print (_("Error: username and password are required to re-register, try re-register --help.\n"))
if not ConsumerIdentity.existsAndValid() and not (self.options.username and self.options.password): print (_("""Error: username and password are required to re-register. \nConsumer identity either does not exists or is corrupted. Try re-register --help."""))
def _validate_options(self): if not ConsumerIdentity.exists() and not (self.options.username and self.options.password): print (_("Error: username and password are required to re-register, try re-register --help.\n")) sys.exit(-1)
if not ConsumerIdentity.exists() and not self.options.consumerid:
if not ConsumerIdentity.existsAndValid() and not self.options.consumerid: log.info("consumer identity is not valid and consumer id was not passed. Deleting old ones and calling register") shutil.rmtree("/etc/pki/consumer", ignore_errors=True)
def _do_command(self):
consumerid = check_registration()['uuid']
def _do_command(self): """ Executes the command. """ self._validate_options()
try: self.cp.unregisterConsumer(consumerid) log.info("--force specified. Successfully unsubscribed the old consumer.") except: log.error("Unable to unregister with consumer %s" % consumerid)
if ConsumerIdentity.existsAndValid(): consumerid = ConsumerIdentity.read().getConsumerId() try: self.cp.unregisterConsumer(consumerid) log.info("--force specified. Successfully unsubscribed the old consumer.") except: log.error("Unable to unregister with consumer %s" % consumerid)
def _do_command(self): """ Executes the command. """ self._validate_options()
if value != cached_facts[key]:
if value != cached_facts[key] and key not in self.graylist:
def delta(self): """ return a dict of any key/values that have changed including new keys or deleted keys """ cached_facts = self.read(self.fact_cache) diff = {} self.facts = self.get_facts() # compare the dicts to see if there is a diff
self.dialog.set_markup(text)
self.dialog.set_markup(xml.sax.saxutils.escape(text))
def __init__ (self, title, text, type="ok", default=None, parent=None): self.rc = None if type == 'ok': buttons = gtk.BUTTONS_OK style = gtk.MESSAGE_INFO elif type == 'warning': buttons = gtk.BUTTONS_OK style = gtk.MESSAGE_WARNING elif type == 'okcancel': buttons = gtk.BUTTONS_OK_CANCEL style = gtk.MESSAGE_WARNING elif type == 'yesno': buttons = gtk.BUTTONS_YES_NO style = gtk.MESSAGE_QUESTION elif type == "error": buttons = gtk.BUTTONS_OK style = gtk.MESSAGE_ERROR elif type == "question": buttons = gtk.BUTTONS_YES_NO style = gtk.MESSAGE_QUESTION
systemExit(-1, msgs=e.msg)
systemExit(-1, msgs=e)
def _do_command(self): """ Executes the command. """ self._validate_options() consumer = check_registration()['uuid'] try: if self.options.product: for product in self.options.product: bundles = self.cp.bindByProduct(consumer, product) log.info("Info: Successfully subscribed the machine to product %s" % product)
"on_first_noncompliant_radiobutton_toggled": self._reload_screen, "on_noncompliant_date_radiobutton_toggled": self._reload_screen,
"on_first_noncompliant_radiobutton_toggled": self._check_for_date_change, "on_noncompliant_date_radiobutton_toggled": self._check_for_date_change,
def __init__(self, backend, consumer, facts): self.backend = backend self.consumer = consumer self.facts = facts self.pool_stash = managerlib.PoolStash(self.backend, self.consumer, self.facts)
self._reload_screen()
self._check_for_date_change(widget)
def _compliance_date_selected(self, widget): """ Callback for the date selector to execute when the date has been chosen. """ log.debug("Compliance date selected.") self.noncompliant_date_radiobutton.set_active(True) self._reload_screen()
def show(self): """ Called by the main window when this page is to be displayed. """ try: self._reload_screen() self.window.show() except RestlibException, e: handle_gui_exception(e, _("Error fetching subscriptions from server: %s")) except Exception, e: handle_gui_exception(e, _("Error displaying Compliance Assistant. Please see /var/log/rhsm/rhsm.log for more information.")) def _reload_screen(self, widget=None): """ Draws the entire screen, called when window is shown, or something changes and we need to refresh. """ log.debug("reloading screen") log.debug(" widget = %s" % widget) self.last_compliant_date = find_last_compliant() noncompliant_date = self._get_noncompliant_date() log.debug("using noncompliance date: %s" % noncompliant_date) self.pool_stash.refresh(active_on=noncompliant_date) if self.last_compliant_date: formatted = self.format_date(self.last_compliant_date) self.compliance_label.set_label( _("All software is in compliance until %s.") % formatted) self.first_noncompliant_radiobutton.set_label( _("%s (first date of non-compliance)") % formatted) self._display_uncompliant() self._display_subscriptions()
def _on_uncompliant_active_toggled(self, cell, path): treeiter = self.uncompliant_store.get_iter_from_string(path) item = self.uncompliant_store.get_value(treeiter, self.uncompliant_store['active']) self.uncompliant_store.set_value(treeiter, self.uncompliant_store['active'], not item)
self.contract_selection.destroy()
if self.contract_selection: self.contract_selection.destroy()
def _contract_selection_cancelled(self): self.contract_selection.destroy() self.contract_selection = None
self._contract_selected(pools.pools[1])
self._contract_selected(pools.pools[0]) return
def subscribe_button_clicked(self, button): model, tree_iter = self.subs_treeview.get_selection().get_selected() pools = model.get_value(tree_iter, self.subs_store['merged_pools']) # Decide if we need to show the contract selection dialog or not. # if there's just one pool, shortcut right to the callback that the # dialog would have run. if len(pools.pools) == 1: self._contract_selected(pools.pools[1])
def __init__(self, username=None, password=None, cert_file=None, key_file=None):
def __init__(self, username=None, password=None, proxy_hostname=None, proxy_port=None, cert_file=None, key_file=None):
def __init__(self, username=None, password=None, cert_file=None, key_file=None): pass
'product_name': ent_cert.getName(),
'product_name': ent_cert.getProduct().getName(),
def _display_uncompliant(self): sorter = CertSorter(self.product_dir, self.entitlement_dir, on_date=self._get_noncompliant_date())
'entitlement': entitlement,
'entitlement': ent_cert,
def _display_uncompliant(self): sorter = CertSorter(self.product_dir, self.entitlement_dir, on_date=self._get_noncompliant_date())
'expires' : cert.validRange().end(),
'expires' : formatDate(cert.validRange().end().isoformat()),
def getInstalledProductStatus(): """ Returns the Installed products and their subscription states """ products = ProductDirectory().list() entcerts = EntitlementDirectory().list() entdict = {} for cert in entcerts: ents = cert.getEntitlements() eproducts = cert.getProducts() for product in eproducts: entdict[product.getName()] = {'Entitlements' : ents, 'valid': cert.valid(), 'expires' : cert.validRange().end(), 'order' : cert.getOrder().getName() } product_status = [] for product in products: pname = product.getProduct().getName() if entdict.has_key(pname): data = (pname, map_status(entdict[pname]['valid']), str(entdict[pname]['expires']), entdict[pname]['order']) product_status.append(data) else: product_status.append((pname, map_status(None), "", "")) # Include entitled but not installed products psnames = [prod[0] for prod in product_status] for cert in EntitlementDirectory().list(): for product in cert.getProducts(): if product.getName() not in psnames: psname = product.getName() data = (psname, 'Not Installed', str(entdict[psname]['expires']), entdict[psname]['order']) product_status.append(data) return product_status
data = (product.getName(), cert.valid(), cert.validRange().begin(), cert.validRange().end())
data = (product.getName(), cert.valid(), formatDate(cert.validRange().begin().isoformat()), \ formatDate(cert.validRange().end().isoformat()))
def getConsumedProductEntitlements(): """ Gets the list of available products with entitlements based on its subscription cert """ entdir = EntitlementDirectory() consumed_products = [] for cert in entdir.listValid(): eproducts = cert.getProducts() for product in eproducts: data = (product.getName(), cert.valid(), cert.validRange().begin(), cert.validRange().end()) consumed_products.append(data) return consumed_products
self.parser.add_option("--consumerid", dest="consumerid", help=_("register to an existing consumer"))
def __init__(self): usage = "usage: %prog register [OPTIONS]" shortdesc = _("register the client to a Unified Entitlement Platform.") desc = "register"
if self.options.consumerid: consumer = self.cp.getConsumerById(self.options.consumerid, self.options.username, self.options.password) elif ConsumerIdentity.exists() and self.options.force:
if ConsumerIdentity.exists() and self.options.force:
def _do_command(self): """ Executes the command. """ self._validate_options()
print consumer, cpserver
print consumer
def getAvailableEntitlementsCLI(cpserver, consumer): columns = ['id', 'quantity', 'unlimited', 'consumed', 'endDate', 'productName', 'productId'] # update facts if we need it print consumer, cpserver facts = getFacts()
log.exception(e) log.error("Error: Unable to ReRegister the system") systemExit(-1, e)
handle_exception("Error: Unable to ReRegister the system", e)
def _do_command(self):
log.exception(e) log.error("Error: Unable to UnRegister the system") systemExit(-1, e)
handle_exception("Error: Unable to UnRegister the system", e)
def _do_command(self): self.add_user_identity() if not ConsumerIdentity.exists(): print(_("This system is currently not registered.")) sys.exit(1)
log.error("Unable to subscribe: %s" % e) log.exception(e) systemExit(-1, msgs=e)
handle_exception("Unable to subscribe: %s" % e, e)
def _do_command(self): """ Executes the command. """ self._validate_options() consumer = check_registration()['uuid'] try: # update facts first, if we need to facts = getFacts()
log.exception(e) log.error("Unable to perform unsubscribe due to the following exception \n Error: %s" % e) systemExit(-1, msgs=e)
handle_exception("Unable to perform unsubscribe due to the following exception \n Error: %s" % e, e)
def _do_command(self): """ Executes the command. """ self.add_user_identity() consumer = check_registration()['uuid'] try: if self.options.serial: self.cp.unBindBySerialNumber(consumer, self.options.serial) log.info("This machine has been Unsubscribed from subcription with Serial number %s" % (self.options.serial)) else: self.cp.unbindAll(consumer) log.info("Warning: This machine has been unsubscribed from all its subscriptions as per user request.") self.certlib.update() except connection.RestlibException, re: log.error(re) systemExit(-1, re.msg) except Exception,e: log.exception(e) log.error("Unable to perform unsubscribe due to the following exception \n Error: %s" % e) systemExit(-1, msgs=e)
register_button.hide() regtoken_button.show() unregister_button.show()
def setRegistrationStatus(self): """ Updates portions of the main window to reflect current registration status. """ exists = ConsumerIdentity.existsAndValid() log.debug("updating registration status.. consumer exists?: %s", exists)
register_button.show() regtoken_button.hide() unregister_button.hide()
set_visible(register_button, not exists) set_visible(regtoken_button, exists) set_visible(unregister_button, exists)
def setRegistrationStatus(self): """ Updates portions of the main window to reflect current registration status. """ exists = ConsumerIdentity.existsAndValid() log.debug("updating registration status.. consumer exists?: %s", exists)
def __init__(self, host='localhost', ssl_port=8443, handler=cfg['prefix'] or "/candlepin",
def __init__(self, host='localhost', ssl_port=8443, handler=config['prefix'] or "/candlepin",
def __init__(self, host='localhost', ssl_port=8443, handler=cfg['prefix'] or "/candlepin", cert_file=None, key_file=None): self.host = host self.ssl_port = ssl_port self.handler = handler self.conn = None self.basic_auth_conn = None self.cert_file = cert_file self.key_file = key_file config = initConfig() self.candlepin_ca_file = config['candlepin_ca_file'] config_insecure = config['insecure'] self.insecure = False if config_insecure: self.insecure = True if self.candlepin_ca_file == None: log.info("Value \'candlepin_ca_file\' not present in config file. Assuming default value: %s", DEFAULT_CA_FILE) self.candlepin_ca_file = DEFAULT_CA_FILE # initialize connection self.conn = Restlib(self.host, self.ssl_port, self.handler, self.cert_file, self.key_file, self.candlepin_ca_file, self.insecure) log.info("Connection Established: host: %s, port: %s, handler: %s" % (self.host, self.ssl_port, self.handler)) log.info("Connection using cert_file: %s, key_file: %s, ca_file: %s insecure_mode: %s" % (self.cert_file, self.key_file, self.candlepin_ca_file, self.insecure)) #log.info("trace: %s" % trace_me())
config = initConfig()
def __init__(self, host='localhost', ssl_port=8443, handler=cfg['prefix'] or "/candlepin", cert_file=None, key_file=None): self.host = host self.ssl_port = ssl_port self.handler = handler self.conn = None self.basic_auth_conn = None self.cert_file = cert_file self.key_file = key_file config = initConfig() self.candlepin_ca_file = config['candlepin_ca_file'] config_insecure = config['insecure'] self.insecure = False if config_insecure: self.insecure = True if self.candlepin_ca_file == None: log.info("Value \'candlepin_ca_file\' not present in config file. Assuming default value: %s", DEFAULT_CA_FILE) self.candlepin_ca_file = DEFAULT_CA_FILE # initialize connection self.conn = Restlib(self.host, self.ssl_port, self.handler, self.cert_file, self.key_file, self.candlepin_ca_file, self.insecure) log.info("Connection Established: host: %s, port: %s, handler: %s" % (self.host, self.ssl_port, self.handler)) log.info("Connection using cert_file: %s, key_file: %s, ca_file: %s insecure_mode: %s" % (self.cert_file, self.key_file, self.candlepin_ca_file, self.insecure)) #log.info("trace: %s" % trace_me())
except connection.RestlibException, re: log.exception(re) errorWindow(constants.UNSUBSCRIBE_ERROR)
def onUnsubscribeAction(self, button): global UEP if not self.psubs_selected: return log.info("Product %s selected for unsubscribe" % self.pname_selected) dlg = messageWindow.YesNoDialog(constants.CONFIRM_UNSUBSCRIBE % xml.sax.saxutils.escape(self.pname_selected), self.mainWin) if not dlg.getrc(): return
log.error("Unable to perform unsubscribe due to the following exception:") log.exception(e) errorWindow(constants.UNSUBSCRIBE_ERROR)
handle_gui_exception(re, constants.UNSUBSCRIBE_ERROR)
def onUnsubscribeAction(self, button): global UEP if not self.psubs_selected: return log.info("Product %s selected for unsubscribe" % self.pname_selected) dlg = messageWindow.YesNoDialog(constants.CONFIRM_UNSUBSCRIBE % xml.sax.saxutils.escape(self.pname_selected), self.mainWin) if not dlg.getrc(): return
managerlib.unregister(UEP, consumer['uuid']) except connection.RestlibException, e:
managerlib.unregister(UEP, consumer['uuid'], False) consumer = get_consumer() self.mainWin.emit(CONSUMER_SIGNAL) except Exception, e:
def showUnregisterDialog(self, button): global UEP, consumer log.info("Unregister called in gui. Asking for confirmation") prompt = messageWindow.YesNoDialog(constants.CONFIRM_UNREGISTER) if not prompt.getrc(): log.info("unregistrater not confirmed. cancelling") return log.info("Proceeding with un-registration: %s", consumer['uuid'])
log.error("Consumer may need to be manually cleaned up: %s" % consumer) log.exception(e) errorWindow(constants.UNREGISTER_ERROR) consumer = get_consumer() self.mainWin.emit(CONSUMER_SIGNAL)
handle_gui_exception(e, constants.UNREGISTER_ERROR, "Consumer may need to be manually cleaned up: %s" % consumer)
def showUnregisterDialog(self, button): global UEP, consumer log.info("Unregister called in gui. Asking for confirmation") prompt = messageWindow.YesNoDialog(constants.CONFIRM_UNREGISTER) if not prompt.getrc(): log.info("unregistrater not confirmed. cancelling") return log.info("Proceeding with un-registration: %s", consumer['uuid'])
log.error("Unable to unregister existing user credentials.") log.exception(e)
handle_gui_exception(e=e, logMsg="Unable to unregister existing user credentials.", showMsg=False)
def register(self, testing=None): self.uname = registration_xml.get_widget("account_login") self.passwd = registration_xml.get_widget("account_password") self.consumer_name = registration_xml.get_widget("consumer_name")
except connection.RestlibException, e: log.error(failed_msg % e.msg) errorWindow(constants.REGISTER_ERROR % linkify(e.msg)) self.close_window() return False
def register(self, testing=None): self.uname = registration_xml.get_widget("account_login") self.passwd = registration_xml.get_widget("account_password") self.consumer_name = registration_xml.get_widget("consumer_name")
log.error(failed_msg % e) errorWindow(constants.REGISTER_ERROR % e) self.close_window() return False
return handle_gui_exception(e, constants.REGISTER_ERROR)
def register(self, testing=None): self.uname = registration_xml.get_widget("account_login") self.passwd = registration_xml.get_widget("account_password") self.consumer_name = registration_xml.get_widget("consumer_name")
except connection.RestlibException, e: log.error("Could not update system facts: error %s" % (e)) errorWindow(linkify(e.msg))
def factsUpdateAction(self, button): facts = getFacts() try: UEP.updateConsumerFacts(consumer['uuid'], facts.get_facts()) except connection.RestlibException, e: log.error("Could not update system facts: error %s" % (e)) errorWindow(linkify(e.msg)) except Exception, e: log.error("Could not update system facts \nError: %s" % (e)) errorWindow(linkify(e.msg))
log.error("Could not update system facts \nError: %s" % (e)) errorWindow(linkify(e.msg))
handle_gui_exception(e, "Could not update facts.\nError: %s" % e)
def factsUpdateAction(self, button): facts = getFacts() try: UEP.updateConsumerFacts(consumer['uuid'], facts.get_facts()) except connection.RestlibException, e: log.error("Could not update system facts: error %s" % (e)) errorWindow(linkify(e.msg)) except Exception, e: log.error("Could not update system facts \nError: %s" % (e)) errorWindow(linkify(e.msg))
except connection.RestlibException, e: log.error("Could not subscribe registration token %s error %s" % (reg_token, e)) errorWindow(linkify(e.msg))
def submitToken(self, button): rlabel = regtoken_xml.get_widget("regtoken_entry") reg_token = rlabel.get_text() elabel = regtoken_xml.get_widget("email_entry") email = elabel.get_text() if email == "": email = None try: UEP.bindByRegNumber(consumer['uuid'], reg_token, email) infoWindow(constants.SUBSCRIBE_REGTOKEN_SUCCESS % reg_token, self.regtokenWin) except connection.RestlibException, e: log.error("Could not subscribe registration token %s error %s" % (reg_token, e)) errorWindow(linkify(e.msg)) except Exception, e: log.error("Could not subscribe registration token [%s] \nError: %s" % (reg_token, e)) errorWindow(constants.SUBSCRIBE_REGTOKEN_ERROR % reg_token)
log.error("Could not subscribe registration token [%s] \nError: %s" % (reg_token, e)) errorWindow(constants.SUBSCRIBE_REGTOKEN_ERROR % reg_token)
handle_gui_exception(e, constants.SUBSCRIBE_REGTOKEN_ERROR % reg_token, "Could not subscribe registration token %s.\nError: %s" % (reg_token, e))
def submitToken(self, button): rlabel = regtoken_xml.get_widget("regtoken_entry") reg_token = rlabel.get_text() elabel = regtoken_xml.get_widget("email_entry") email = elabel.get_text() if email == "": email = None try: UEP.bindByRegNumber(consumer['uuid'], reg_token, email) infoWindow(constants.SUBSCRIBE_REGTOKEN_SUCCESS % reg_token, self.regtokenWin) except connection.RestlibException, e: log.error("Could not subscribe registration token %s error %s" % (reg_token, e)) errorWindow(linkify(e.msg)) except Exception, e: log.error("Could not subscribe registration token [%s] \nError: %s" % (reg_token, e)) errorWindow(constants.SUBSCRIBE_REGTOKEN_ERROR % reg_token)
log.error("Failed to subscribe to product %s Error: %s" % (state[1], e)) errorWindow(constants.SUBSCRIBE_ERROR % state[1])
handle_gui_exception(e, constants.SUBSCRIBE_ERROR % state[1], "Failed to subscribe to product %s Error: %s" % (state[1], e))
def onSubscribeAction(self, button): subscribed_count = 0 my_model = self.tv_products.get_model() for pool, state in self.selected.items(): # state = (bool, iter) if state[0]: try: ent_ret = UEP.bindByEntitlementPool(consumer['uuid'], pool) entitled_data = ent_ret[0]['pool'] updated_count = str(int(entitled_data['quantity']) - int(entitled_data['consumed'])) my_model.set_value(state[-1], 2, updated_count) subscribed_count += 1 except Exception, e: # Subscription failed, continue with rest log.error("Failed to subscribe to product %s Error: %s" % (state[1], e)) errorWindow(constants.SUBSCRIBE_ERROR % state[1]) continue # Force fetch all certs if not fetch_certificates(): return if subscribed_count: slabel.set_label(constants.SUBSCRIBE_SUCCSSFUL % subscribed_count) self.updateWin.hide() # refresh main window else: slabel.set_label(constants.ATLEAST_ONE_SELECTION) self.gui_reload()
errorWindow(_(callback(e)))
errorWindow(callback(e))
def handle_gui_exception(e, callback, logMsg = None, showMsg = True): if logMsg: log.error(logMsg) log.exception(e) if showMsg: if isinstance(e, socket_error): errorWindow(_('network error, unable to connect to server')) elif isinstance(e, SSL.SSLError): errorWindow(_('Unable to verify server\'s identity: %s' % str(e))) elif isinstance(e, connection.RestlibException): errorWindow(callback % linkify(e.msg)) else: if hasattr(callback, '__call__'): errorWindow(_(callback(e))) else: errorWindow(_(callback)) #just a string return False
errorWindow(_(callback))
errorWindow(callback)
def handle_gui_exception(e, callback, logMsg = None, showMsg = True): if logMsg: log.error(logMsg) log.exception(e) if showMsg: if isinstance(e, socket_error): errorWindow(_('network error, unable to connect to server')) elif isinstance(e, SSL.SSLError): errorWindow(_('Unable to verify server\'s identity: %s' % str(e))) elif isinstance(e, connection.RestlibException): errorWindow(callback % linkify(e.msg)) else: if hasattr(callback, '__call__'): errorWindow(_(callback(e))) else: errorWindow(_(callback)) #just a string return False
systemExit(-1, e)
systemExit(-1, ex)
def handle_exception(msg, ex): log.error(msg) log.exception(ex) if isinstance(ex, socket_error): print 'network error, unable to connect to server' sys.exit(-1) else: systemExit(-1, e)
pacparser_module_path = glob.glob(os.path.join(tests_dir, '..', 'pymod', 'build', 'lib*'))[0] except: print 'Tests failed. Could not determine pacparser path.\n%s' % str(e)
pacparser_module_path = glob.glob(os.path.join( tests_dir, '..', 'pymod', 'build', 'lib*%s' % py_ver))[0] except Exception: print 'Tests failed. Could not determine pacparser path.'
def runtests(pacfile, testdata, tests_dir): try: pacparser_module_path = glob.glob(os.path.join(tests_dir, '..', 'pymod', 'build', 'lib*'))[0] except: print 'Tests failed. Could not determine pacparser path.\n%s' % str(e) return 1 sys.path.insert(0, pacparser_module_path) try: import pacparser except ImportError, e: print 'Tests failed. Could not import pacparser.\n%s' % str(e) return 1 f = open(testdata) for line in f: if line.startswith('#'): continue if 'DEBUG' in os.environ: print line (params, expected_result) = line.strip().split('|') args = dict(getopt.getopt(params.split(), 'eu:c:')[0]) if '-e' in args: pacparser.enable_microsoft_extensions() if '-c' in args: pacparser.setmyip(args['-c']) pacparser.init() pacparser.parse_pac(pacfile) result = pacparser.find_proxy(args['-u']) pacparser.cleanup() if result != expected_result: print 'Tests failed. Got "%s", expected "%s"' % (result, expected_result) return 1 print 'All tests were successful.'
except ImportError, e: print 'Tests failed. Could not import pacparser.\n%s' % str(e)
except ImportError: print 'Tests failed. Could not import pacparser.'
def runtests(pacfile, testdata, tests_dir): try: pacparser_module_path = glob.glob(os.path.join(tests_dir, '..', 'pymod', 'build', 'lib*'))[0] except: print 'Tests failed. Could not determine pacparser path.\n%s' % str(e) return 1 sys.path.insert(0, pacparser_module_path) try: import pacparser except ImportError, e: print 'Tests failed. Could not import pacparser.\n%s' % str(e) return 1 f = open(testdata) for line in f: if line.startswith('#'): continue if 'DEBUG' in os.environ: print line (params, expected_result) = line.strip().split('|') args = dict(getopt.getopt(params.split(), 'eu:c:')[0]) if '-e' in args: pacparser.enable_microsoft_extensions() if '-c' in args: pacparser.setmyip(args['-c']) pacparser.init() pacparser.parse_pac(pacfile) result = pacparser.find_proxy(args['-u']) pacparser.cleanup() if result != expected_result: print 'Tests failed. Got "%s", expected "%s"' % (result, expected_result) return 1 print 'All tests were successful.'
if target == 'install':
if len(sys.argv) > 1 and sys.argv[1] == 'install':
def main(): if sys.platform == 'win32': #install target is used to just install compiled files. if target == 'install': import shutil install_path = '%s\Lib\site-packages\pacparser' % sys.prefix if os.path.isdir(install_path): shutil.rmtree(install_path) shutil.copytree('.', install_path) else: pydll = 'C:\windows\system32\python%s.dll' % ver.replace('.', '') os.system('make -f Makefile.win32 %s PY_HOME="%s" PY_DLL="%s"' % (target, sys.prefix, pydll)) return pacparser_module = Extension('_pacparser', include_dirs = ['../spidermonkey/js/src', '..'], sources = ['pacparser_py.c'], extra_objects = ['../pacparser.o', '../libjs.a']) setup (name = 'pacparser', version = '1.1.1', description = 'Pacparser package', author = 'Manu Garg', author_email = 'manugarg@gmail.com', url = 'http://code.google.com/p/pacparser', long_description = 'python library to parse proxy auto-config (PAC) ' 'files.', license = 'LGPL', ext_package = 'pacparser', ext_modules = [pacparser_module], py_modules = ['pacparser.__init__'])
install_path = '%s\Lib\site-packages\pacparser' % sys.prefix if os.path.isdir(install_path): shutil.rmtree(install_path) shutil.copytree('.', install_path)
if os.path.isdir('dist'): install_path = '%s\pacparser' % sysconfig.get_python_lib() if os.path.isdir(install_path): shutil.rmtree(install_path) shutil.copytree('dist', install_path) else: print ('"dist" dir not found. You should run "python setup.py dist"' ' first.')
def main(): if sys.platform == 'win32': #install target is used to just install compiled files. if target == 'install': import shutil install_path = '%s\Lib\site-packages\pacparser' % sys.prefix if os.path.isdir(install_path): shutil.rmtree(install_path) shutil.copytree('.', install_path) else: pydll = 'C:\windows\system32\python%s.dll' % ver.replace('.', '') os.system('make -f Makefile.win32 %s PY_HOME="%s" PY_DLL="%s"' % (target, sys.prefix, pydll)) return pacparser_module = Extension('_pacparser', include_dirs = ['../spidermonkey/js/src', '..'], sources = ['pacparser_py.c'], extra_objects = ['../pacparser.o', '../libjs.a']) setup (name = 'pacparser', version = '1.1.1', description = 'Pacparser package', author = 'Manu Garg', author_email = 'manugarg@gmail.com', url = 'http://code.google.com/p/pacparser', long_description = 'python library to parse proxy auto-config (PAC) ' 'files.', license = 'LGPL', ext_package = 'pacparser', ext_modules = [pacparser_module], py_modules = ['pacparser.__init__'])
pydll = 'C:\windows\system32\python%s.dll' % ver.replace('.', '')
pydll = ('C:\windows\system32\python%s.dll' % sysconfig.get_config_vars('VERSION')[0])
def main(): if sys.platform == 'win32': #install target is used to just install compiled files. if target == 'install': import shutil install_path = '%s\Lib\site-packages\pacparser' % sys.prefix if os.path.isdir(install_path): shutil.rmtree(install_path) shutil.copytree('.', install_path) else: pydll = 'C:\windows\system32\python%s.dll' % ver.replace('.', '') os.system('make -f Makefile.win32 %s PY_HOME="%s" PY_DLL="%s"' % (target, sys.prefix, pydll)) return pacparser_module = Extension('_pacparser', include_dirs = ['../spidermonkey/js/src', '..'], sources = ['pacparser_py.c'], extra_objects = ['../pacparser.o', '../libjs.a']) setup (name = 'pacparser', version = '1.1.1', description = 'Pacparser package', author = 'Manu Garg', author_email = 'manugarg@gmail.com', url = 'http://code.google.com/p/pacparser', long_description = 'python library to parse proxy auto-config (PAC) ' 'files.', license = 'LGPL', ext_package = 'pacparser', ext_modules = [pacparser_module], py_modules = ['pacparser.__init__'])
(target, sys.prefix, pydll))
(' '.join(sys.argv[1:]), sys.prefix, pydll))
def main(): if sys.platform == 'win32': #install target is used to just install compiled files. if target == 'install': import shutil install_path = '%s\Lib\site-packages\pacparser' % sys.prefix if os.path.isdir(install_path): shutil.rmtree(install_path) shutil.copytree('.', install_path) else: pydll = 'C:\windows\system32\python%s.dll' % ver.replace('.', '') os.system('make -f Makefile.win32 %s PY_HOME="%s" PY_DLL="%s"' % (target, sys.prefix, pydll)) return pacparser_module = Extension('_pacparser', include_dirs = ['../spidermonkey/js/src', '..'], sources = ['pacparser_py.c'], extra_objects = ['../pacparser.o', '../libjs.a']) setup (name = 'pacparser', version = '1.1.1', description = 'Pacparser package', author = 'Manu Garg', author_email = 'manugarg@gmail.com', url = 'http://code.google.com/p/pacparser', long_description = 'python library to parse proxy auto-config (PAC) ' 'files.', license = 'LGPL', ext_package = 'pacparser', ext_modules = [pacparser_module], py_modules = ['pacparser.__init__'])
if len(sys.argv) < 2: target = '' else: target = sys.argv[1]
def main(): if sys.platform == 'win32': #install target is used to just install compiled files. if target == 'install': import shutil install_path = '%s\Lib\site-packages\pacparser' % sys.prefix if os.path.isdir(install_path): shutil.rmtree(install_path) shutil.copytree('.', install_path) else: pydll = 'C:\windows\system32\python%s.dll' % ver.replace('.', '') os.system('make -f Makefile.win32 %s PY_HOME="%s" PY_DLL="%s"' % (target, sys.prefix, pydll)) return pacparser_module = Extension('_pacparser', include_dirs = ['../spidermonkey/js/src', '..'], sources = ['pacparser_py.c'], extra_objects = ['../pacparser.o', '../libjs.a']) setup (name = 'pacparser', version = '1.1.1', description = 'Pacparser package', author = 'Manu Garg', author_email = 'manugarg@gmail.com', url = 'http://code.google.com/p/pacparser', long_description = 'python library to parse proxy auto-config (PAC) ' 'files.', license = 'LGPL', ext_package = 'pacparser', ext_modules = [pacparser_module], py_modules = ['pacparser.__init__'])