473,769 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unknown errors, RSS feed

11 New Member
From my other post I am making a simple program that creates an RSS feed with Python. Now when I run my program so far, I get errors. It says "something is not defined". The word something is replaced by the name of the function I'm trying to use. my article function when ran, comes up with "article is not defined" etc.

Here's my code: What is wrong with it?

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/env python
  2. import ftplib
  3. import getpass
  4.  
  5. def mainfeed():
  6.     name=raw_input("Name of Feed: ")
  7.     desc=raw_input("Description of Feed: ")
  8.     url=raw_input("Location of Website: ")
  9.     again()
  10.  
  11. def again():
  12.     again=raw_input("Would you like to add an article to the feed? Y/N: ")
  13.     if again == "Y":
  14.         article()
  15.     elif again =="N":
  16.         writeb()
  17.     else:
  18.         print again + """is not a valid option. You must select either 'Y' or 'N'"""
  19.         fail()
  20.  
  21. def fail():
  22.     again()
  23.  
  24. def article():
  25.     aname=raw_input("Name of Article: ")
  26.     adesc=raw_input("Description of Article: ")
  27.     aurl=raw_input("Location of Article: ")
  28.     finish()
  29.  
  30. def finish():
  31.     print "Saving parameters to rss-feed.xml...please wait..."
  32.     print "Finished"   
  33.     writea()
  34.  
  35. def writea():
  36.     file_name = "rss-feed.xml"
  37.     f = open(file_name, 'w')
  38.     outlist = ['<?xml version="1.0" encoding="ISO-8859-1" ?>', '<rss version="0.91">',]
  39.     outlist.append('  <channel>\n    <title>%s</title>' % name)
  40.     outlist.append('    <link>%s</link>' % url)
  41.     outlist.append('    <description>%s</description>' % desc)
  42.     outlist.append('    <item>\n        <title>%s</title>' % aname)
  43.     outlist.append('        <link>%s</link>' % aurl)
  44.     outlist.append('        <description>%s</description>' % adesc)
  45.     outlist.append('    </item>')
  46.     outlist.append('  </channel>')
  47.     outlist.append('</rss>')  
  48.     f.write('\n'.join(outlist))
  49.     f.close()
  50.     ftpqe()
  51.  
  52. def writeb():
  53.     file_name = "rss-feed.xml"
  54.     f = open(file_name, 'w')
  55.     outlist = ['<?xml version="1.0" encoding="ISO-8859-1" ?>', '<rss version="0.91">',]
  56.     outlist.append('  <channel>\n    <title>%s</title>' % name)
  57.     outlist.append('    <link>%s</link>' % url)
  58.     outlist.append('    <description>%s</description>' % desc)
  59.     outlist.append('  </channel>')
  60.     outlist.append('</rss>')  
  61.     f.write('\n'.join(outlist))
  62.     f.close()
  63.     ftpqe()
  64.  
  65. def ftpqe():
  66.     ftpq=raw_input("Do you want to upload your XML file to your website via FTP? Y/N: ")
  67.     if ftpq == "Y":
  68.         ftp()
  69.     elif ftpq =="N":
  70.         end()
  71.     else:
  72.         print again + """is not a valid option. You must select either 'Y' or 'N'"""
  73.         fail2()
  74.  
  75. def fail2():
  76.     ftpqe()
  77.  
  78. def ftp():
  79.     server=raw_input("Server name: ")
  80.     login=raw_input("Enter your login: ")
  81.     password = getpass.unix_getpass("Enter your password: ")
  82.     ftplib.FTP(server,login,password)
  83.     f = open('rss-feed.xml','rb') 
  84.     s.storbinary('STOR rss-feed.xml', f)
  85.     f.close()
  86.     s.quit()
  87.     print "Your file has been uploaded"
  88.     end()
  89.  
  90. def end():
  91.     print "Thank you"
  92.  
  93. mainfeed()
Dec 24 '08
10 2387
bvdet
2,851 Recognized Expert Moderator Specialist
You're welcome. You did a good job of defining your problem and seeing the thread through. Fortunately, I was able to help.

-BV
Dec 24 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
8672
by: Amy | last post by:
This is what I want to do: 1. Delete all tables in database with table names that ends with a number. 2. Leave all other tables in tact. 3. Table names are unknown. 4. Numbers attached to table names are unknown. 5. Unknown number of tables in database. For example:
8
7423
by: Spartanicus | last post by:
The document at http://homepage.ntlworld.com/spartanicus/custom_dtd.htm uses a custom DTD, the w3c validator validates it but with this warning: "Unknown Parse Mode! The MIME Media Type (text/html) for this document is used to serve both SGML and XML based documents, and it is not possible to disambiguate it based on the DOCTYPE Declaration in your document. Parsing will continue in SGML mode."...
3
5240
by: Torrent | last post by:
When Trying to Load an XSLT File with the XslTransform i got a rather annoying Exception being thrown "System.Xml.XPath.XPathException: XsltContext is needed for this query because of an unknown function." It was annoying because I had checked created the whole document and tested it in Internet Explorer 6.0 and everything worked perfectly; no errors or warnings. After doing research i found out that most often times the error that i was...
6
2720
by: quilkin | last post by:
I am getting a System.Data.SqlClient.SqlException with a message string of 'Unknown Error'. Happens occasionally when creating a "new SqlCommand(...)" while the same command works perfectly happily hundreds of other times. A side effect is that the connection closes. ..NET version is 1.1, same thing happens on various machines, but seems to happen more often on slower ones. Any ideas?
0
2166
by: Shaun | last post by:
Hi all, I'm trying to implement a custom session handler that writes session data to a MySQL database. It works fine about 99% of the time. Trouble is, at random intervals, I get entries like the following in my php-error.log: PHP Warning: Unknown: A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0
5
1954
by: Peter Afonin | last post by:
Hello, I'm developing an Atlas application in ASP.NET 2.0. Everything was OK, but suddenly I started to get some strange errors on one of the pages: When I click any button or invoke any server-side script, I'm getting a popup window: "Unknown error". So I'm stuck. There is no error number, so I cannot investigate it further. There are no errors on the server side - when I debug, everything is OK, the
5
13690
by: fjanon | last post by:
Hi, I went through the HTML spec without finding the description of what the browsers behavior should/must be regarding tags or attributes they don't understand. I did a quick experiment like this: <mytag style='display:none'> <h3>Hello</h3>
0
1690
by: S.T | last post by:
Hi! I've spend this weekend trying and coding a php-based atom- and rss-feed writer. I don't know if this is the right place for my questions. However, since both feeds are based on xml, maybe someone can help. I understand that I have to replace all unknown entities, such as "&auml;". I wonder what's the common way to do so. For XML-Documents, I'd prefer to make use of an external DTD, say, referring to
2
7394
by: Calvin Cheng | last post by:
Hi, I am attempting to convert a bunch of .txt files into html using the docutils package. It works for most of the txt files except for the index.txt file which gives 2 errors: (1) <Error/3Unknown Directive type "toctree" (2) (ERROR/3) Unknown interpreted text role "ref".
0
9589
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9995
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7410
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.