Hello,
I am currently trying to write some scripts to get information from the
xmlrpc for redhat network. One of the issues I am having is trying to
strip off the special characters in the hash that is returned. Here is
an example of the information returned within the hash :
===SNIP===
{'errata_update_date': '2005-12-06', 'errata_topic': 'Updated
libc-client packages that fix a buffer overflow issue are
now\navailable.\n\nThis update has been rated as having moderate
security impact by the Red\nHat Security Response Team.',
'errata_type': 'Security Advisory', 'errata_notes': '',
'errata_synopsis': 'Moderate: libc-client security update',
'errata_references': '', 'errata_last_modified_date': '2006-01-25
10:37:24', 'errata_issue_date': '2005-12-06', 'errata_description':
'C-client is a common API for accessing mailboxes.\n\nA buffer overflow
flaw was discovered in the way C-client parses user\nsupplied
mailboxes. If an authenticated user requests a specially
crafted\nmailbox name, it may be possible to execute arbitrary code on
a server that\nuses C-client to access mailboxes. The Common
Vulnerabilities and Exposures\nproject has assigned the name
CVE-2005-2933 to this issue.\n\nAll users of libc-client should upgrade
to these updated packages, which\ncontain a backported patch that
resolves this issue.'}
===SNIP===
What I would like to do is remove the \n characters from
'errata_topic'. Which is this section of the hash.
Updated libc-client packages that fix a buffer overflow issue are
now\navailable.\n\nThis update has been rated as having moderate
security impact by the Red\nHat Security Response Team.
What I had attempted to do is use the replace() function but it
consistantly comes up with the following errors:
Traceback (most recent call last):
File "rhn_errata.py", line 63, in ?
errata_package = errata_package.strip('\n','')
AttributeError: 'dict' object has no attribute 'strip'
where errata_package is JUST the errata_topic hash value.
Any advice would be great on how to do that.
Regards,
Johhny 10 1200
On Thu, 2006-01-26 at 09:24, Johhny wrote: Hello,
I am currently trying to write some scripts to get information from the xmlrpc for redhat network. One of the issues I am having is trying to strip off the special characters in the hash that is returned. Here is an example of the information returned within the hash :
===SNIP=== {'errata_update_date': '2005-12-06', 'errata_topic': 'Updated libc-client packages that fix a buffer overflow issue are now\navailable.\n\nThis update has been rated as having moderate security impact by the Red\nHat Security Response Team.',
[...]
What I had attempted to do is use the replace() function but it consistantly comes up with the following errors:
Traceback (most recent call last): File "rhn_errata.py", line 63, in ? errata_package = errata_package.strip('\n','') AttributeError: 'dict' object has no attribute 'strip'
where errata_package is JUST the errata_topic hash value.
errata_package is obviously not just the errata_topic hash value,
because that would be a string, and python for some reason seems to
believe that errata_package is a dictionary.
Also note that once you correct that problem, python will complain that
strip() doesn't take 2 parameters, since you actually mean replace().
-Carsten
Hello,
Thankyou for your response,
If I check that the errara_package value is with a print I get the
following.
===SNIP===
Updated libc-client packages that fix a buffer overflow issue are now
available.
This update has been rated as having moderate security impact by the
Red
Hat Security Response Team.
===SNIP===
Notice that it has formatted the output with the \n's.
So i dont understand why its reporting as a dictionary rather than just
the string.
On Thu, 2006-01-26 at 09:49, Johhny wrote: Hello,
Thankyou for your response, If I check that the errara_package value is with a print I get the following.
===SNIP=== Updated libc-client packages that fix a buffer overflow issue are now available.
This update has been rated as having moderate security impact by the Red Hat Security Response Team. ===SNIP===
Notice that it has formatted the output with the \n's.
So i dont understand why its reporting as a dictionary rather than just the string.
Posting relevant bits of your code might help.
-Carsten
Hello,
Here is the code (minus my details section).
server = xmlrpclib.ServerProxy(url)
session = server.auth.login(username,password)
#functions.
def getErrata():
channel_label = 'rhel-i386-as-4'
errata =
server.channel.software.list_errata(session,channe l_label,start_date,end_date)
return errata
def getPackage(advisory):
Package = server.errata.get_details(session,advisory)
return Package
errata = getErrata()
for vals in errata:
print "%s\t\t%s\t\t%s\t%s\t%s" %
(vals['errata_advisory'],vals['errata_issue_date'],vals['errata_update_date'],vals['errata_last_modified_date'],vals['errata_type'],)
errata_info = getPackage(vals['errata_advisory'],)
print errata_info['errata_topic']
errata_package = errata_info['errata_topic']
print getPackage(vals['errata_advisory'])
I have not got any of the section in to replace the \n's as I was
trying to work out why its not seeing what I thought was a string as a
dict.
Johhny wrote: Hello,
I am currently trying to write some scripts to get information from the xmlrpc for redhat network. One of the issues I am having is trying to strip off the special characters in the hash that is returned. Here is an example of the information returned within the hash :
===SNIP=== {'errata_update_date': '2005-12-06', 'errata_topic': 'Updated libc-client packages that fix a buffer overflow issue are now\navailable.\n\nThis update has been rated as having moderate security impact by the Red\nHat Security Response Team.', 'errata_type': 'Security Advisory', 'errata_notes': '', 'errata_synopsis': 'Moderate: libc-client security update', 'errata_references': '', 'errata_last_modified_date': '2006-01-25 10:37:24', 'errata_issue_date': '2005-12-06', 'errata_description': 'C-client is a common API for accessing mailboxes.\n\nA buffer overflow flaw was discovered in the way C-client parses user\nsupplied mailboxes. If an authenticated user requests a specially crafted\nmailbox name, it may be possible to execute arbitrary code on a server that\nuses C-client to access mailboxes. The Common Vulnerabilities and Exposures\nproject has assigned the name CVE-2005-2933 to this issue.\n\nAll users of libc-client should upgrade to these updated packages, which\ncontain a backported patch that resolves this issue.'} ===SNIP===
What I would like to do is remove the \n characters from 'errata_topic'. Which is this section of the hash.
Updated libc-client packages that fix a buffer overflow issue are now\navailable.\n\nThis update has been rated as having moderate security impact by the Red\nHat Security Response Team.
What I had attempted to do is use the replace() function but it consistantly comes up with the following errors:
Traceback (most recent call last): File "rhn_errata.py", line 63, in ? errata_package = errata_package.strip('\n','') AttributeError: 'dict' object has no attribute 'strip'
where errata_package is JUST the errata_topic hash value.
Any advice would be great on how to do that.
Regards,
Johhny
You must use 'errata_topic' as index into your dictionary
to get the string and then replace the \n chars.
Example assumes that the dict is pointed to by d):
errata_topic_text=d['errata_topic'].replace('\n',' ')
Hope this helps.
Larry Bates
Johhny wrote: for vals in errata:
print "%s\t\t%s\t\t%s\t%s\t%s" %
(vals['errata_advisory'],vals['errata_issue_date'],vals['errata_update_date'],vals['errata_last_modified_date'],vals['errata_type'],
) errata_info = getPackage(vals['errata_advisory'],)
print errata_info['errata_topic']
errata_package = errata_info['errata_topic']
add
print type(errata_package), repr(errata_package)
here, and let us know what it prints.
print getPackage(vals['errata_advisory'])
</F>
Johhny wrote: Hello,
Here is the code (minus my details section).
server = xmlrpclib.ServerProxy(url)
session = server.auth.login(username,password)
#functions.
def getErrata():
channel_label = 'rhel-i386-as-4'
errata = server.channel.software.list_errata(session,channe l_label,start_date,end_date)
return errata def getPackage(advisory):
Package = server.errata.get_details(session,advisory)
return Package errata = getErrata()
for vals in errata:
print "%s\t\t%s\t\t%s\t%s\t%s" % (vals['errata_advisory'],vals['errata_issue_date'],vals['errata_update_date'],vals['errata_last_modified_date'],vals['errata_type'],)
errata_info = getPackage(vals['errata_advisory'],)
print errata_info['errata_topic']
errata_package = errata_info['errata_topic']
errata_package = errata_info['errata_topic'].replace('\n', " ") print getPackage(vals['errata_advisory'])
I have not got any of the section in to replace the \n's as I was trying to work out why its not seeing what I thought was a string as a dict.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
Hello,
In response to that the output is this :
<type 'str'> 'Updated libc-client packages that fix a buffer overflow
issue are now\navailable.\n\nThis update has been rated as having
moderate security impact by the Red\nHat Security Response Team.'
Hello All,
thanks for your help. I got it working and learnt some more things
which is always great. Your assitance has been very useful.
Regards,
Johhny
(since this is a newsgroup, can you please quote the message
you're replying to).
Johhny wrote: In response to that the output is this :
<type 'str'> 'Updated libc-client packages that fix a buffer overflow issue are now\navailable.\n\nThis update has been rated as having moderate security impact by the Red\nHat Security Response Team.'
<type 'str> means that it *is* a string, after all. looks like you didn't
post the code you were using :-(
replacing the print statement with
errata_package = errata_package.replace("\n", " ")
should do what you want.
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike |
last post by:
I have created a side application in VB.NET which reads
rows from a DB and builds an email message.
when i have a long string the the mailmessage.body or the
mailmessage, it puts in an...
|
by: Adam J. Schaff |
last post by:
I am writing a quick program to edit a binary file that contains file paths
(amongst other things). If I look at the files in notepad, they look like:
...
|
by: Alain |
last post by:
Hi,
I am working on a project where I need to convert international characters
with acii values. Like André -> andre and Björn -> bjorn.
How can I do this without replacing every single...
|
by: Adnan Siddiqi |
last post by:
Hi
Suppose I have following URLs comming from an HTML document
<a href="http://mydomain1.com">Domain1</a>
<a...
|
by: David |
last post by:
Sent this to alt.php a couple of days back, but doesn't look like I'll
get an answer, so trying here.
I'm trying to convert a script to use friendly URLs, I've done this
before, but my PHP...
| |
by: =?Utf-8?B?am1obWFpbmU=?= |
last post by:
I'm trying to create a process that allows me to limit the non-alphanumeric
characters generated with the PasswordRecovery control. Specially I want to
suppress some characters for security...
|
by: Trev |
last post by:
Hi everyone,
I'm having some problems using Regex; I have a long string that is
delimetered in a random fashion by a combination of spaces and \n's for
newlines. I have five possiblities:
//...
|
by: DL |
last post by:
Hi,
Our school has an application in which :
- Teachers enter comments through a web interface built in asp (not
asp.net).
- Comments are stored in a SQL server 2000 (in a nText field)
-...
|
by: gsuns82 |
last post by:
Hi all,
I have to replace accented characters from a input string with
normal plain text.I have coded as follows.
String input = "ÄÀÁÂÃ";
input=...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |