awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Sat Jul 29, 2017 6:37 am

I have script returned data from Awasu, but I want get results in format below to Awasu:

Code: Select all

Channel_name_result1
       feed 1
       feed 2
       feed n
Channel_name_result2
       feed 1
       feed 2
       feed n
Channel_name_resultn
       feed 1
       feed 2
       feed n


So then in docs code for this is:

Name this part of code "Generating Channel"

Code: Select all

print "<rss>"
print "<channel>"
print
print "<title>Sample Python Channel</title>"
print "<link>" + HOME_URL + "</link>"
print "<description>This is a dummy RSS feed generated by the sample Python channel plugin.</description>"
print
for i in range(1,NFEEDITEMS+1) :
    print "<item>"
    print "    <title>Item " + str(i) + "</title>"
    print "    <link>" + HOME_URL + "/item" + str(i) + ".html</link>"
    print "    <description>This is a dummy description for item " + str(i) + "</description>"
    print "</item>"
    print
print "</channel>"
print "</rss>"


It will be correct for Awasu if I code above simple looped:
Generating Channel 1
Generating Channel 2
Generating Channel n
(rss close tag on the end of loop)

This output will be correct interpreted by Awasu? Idea is agregate result from unread items and few channels and back them to Awasu as lists of items in channels where channel name is matched result and results are unread articles. In firts pseudocode feed means "unread article from feed".

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sat Jul 29, 2017 6:56 am

It should work, give it a go :) For a quick test, you can save the generated output to a file, then create a channel that "subscribes" to that file (choose "Read from a file" in the Channel Wizard). You don't even have to create a channel, just go to the second page of the Channel Wizard, click on "Show feed" to see what the feed looks like, then cancel the wizard.

The only thing to watch out for is that the feed items in this new channel will now be returned as search results, which is probably not what you want. Tick "Exclude from search" in the Advanced tab of the channel's Properties dialog to fix this.

awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Sat Jul 29, 2017 1:42 pm

I'll try. Before that I have some technical question. When article get states:

new
unread?

From Awasu I get only new state, but not unread. Could you explain me relation between them? (I want match only unread articles).

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sat Jul 29, 2017 2:17 pm

new = an item has been received since you last opened the channel (i.e. when you open the channel, items will go from "new" to "unread")
read = you have clicked on an item's link
unread = you have not clicked on an item's link

Note that you can control an item's read/unread status (right-click in the item pane and choose "Mark as (un)read"), but not its "new" status.

awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Sat Jul 29, 2017 2:21 pm

I test output from channel generation. I get in Awasu:

Code: Select all

XML parse failed (4:L43:C14): not well-formed (invalid token)


It's another isseu with character coding? I simply use print("") in Python... Should I decode it to UTF-8?

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sat Jul 29, 2017 2:34 pm

You need to look at the XML and determine the exact nature of the error, but yes, it's probably an encoding issue :-)

You have to encode your XML using something, and unless you have a reason to choose something else, UTF8 is probably the best choice. Don't forget to declare what encoding you're using at the top of the XML as well.

awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Sat Jul 29, 2017 6:13 pm

I declared utf-8 and try open python file in Awasu wizard. I get error:

Code: Select all

Error: Can't determine the feed type.
Channel feed: C:\Python\Python36\python.exe: can't open file '%L': [Errno 2] No such file or directory


Could you explain me what is going on? Structure is correct with RSS 2.0 specification. If I try by dump file with xml extension Awasu not showin any error. My script need time (below 2 minutes) to send output because first it must be processed before showing.

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sun Jul 30, 2017 1:34 am

Can you run (as a plugin) the sample scripts that come with Awasu? If not, the .py extension needs to be associated with your python.exe i.e. if you double-click on a .py file in Windows Explorer, Python should start.

If this is setup correctly (and it looks like it is), it looks like you may have specified an incorrect path to your script (use an absolute path).

awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Sun Jul 30, 2017 7:35 am

File .py after clicking run script in Windows correctly so problem is in another place.

What I do?
Steps:

    Ctrl+N
    1. Select: Generated by a channel plugin
    2. In Plugin: I click on folder icon and select .py file. On plugin I have full path C:\script\awasu_pg.py
    3. Click Next
    4. Result: Error is showing: Channel feed errorSelect: Generated by a channel plugin

What I do wrong?

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sun Jul 30, 2017 7:49 am

Can you create a channel for one of the samples that comes with Awasu?

awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Sun Jul 30, 2017 8:11 am

Except I use Python 3 error is the same. It should be error from script (print format).

Code: Select all

Error: Can't determine the feed type.
python.exe: can't open file '%L': [Errno 2] No such file or directory


For quick test I use code too:

Code: Select all

rss_data = '''
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
  <title>W3Schools Home Page</title>
  <link>https://www.w3schools.com</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>https://www.w3schools.com/xml/xml_rss.asp</link>
    <description>New RSS tutorial on W3Schools</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>https://www.w3schools.com/xml</link>
    <description>New XML tutorial on W3Schools</description>
  </item>
</channel>

</rss>
'''
print(rss_data)


Question

I use generated file to test in Awasu. File was correct, but Awasu only found first channel :help: . Is a posibility deal with it or I have not choice but for each channel generate separated script? Idea is with one script generate few channels at once. :D

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sun Jul 30, 2017 8:44 am

Now, I'm not sure what you're asking...

If the plugin is not running at all, create a file called GLOBAL.INI in the Awasu installation directory that looks like this:

Code: Select all

[Script File Types]
.py = Python script
[Scripting File Associations]
.py = C:\Python\Python36\python.exe

and restart Awasu. This overrides the Registry settings Windows uses to figure out what program to run for a given file extension.

(OR) The plugin is running, it's just not doing what you want...?

Plugins can have parameters, so you have one script producing different feeds. Look at the SamplePythonChannel2 example in the Samples sub-directory for an example. More info here as well.

awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Sun Jul 30, 2017 11:07 am

support wrote:Now, I'm not sure what you're asking...


When I'm waiting for answer I test data from file as you sugested before to validate result before running script. So I'm asking about two things:

1. How print result from python script to Awasu [Resolved by GLOBAL.INI]
2. How format output for Awasu to detect multi channel in one script [Still unresolved].

I extend question 2.

a) I'm asking not how make script, but how channel shoudl be correct format on output for Awasu. Basic RSS channel structure is:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
  <title>W3Schools Home Page</title>
  <link>https://www.w3schools.com</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>https://www.w3schools.com/xml/xml_rss.asp</link>
    <description>New RSS tutorial on W3Schools</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>https://www.w3schools.com/xml</link>
    <description>New XML tutorial on W3Schools</description>
  </item>
</channel>

</rss>


Now I'm duplicating channel tags and Awasu detect only first. In suggested example is generated only one feed by running, but my final looks like:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
<title>W3Schools Home Page 1</title>
<link>https://www.w3schools.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS Tutorial</title>
<link>https://www.w3schools.com/xml/xml_rss.asp</link>
<description>New RSS tutorial on W3Schools</description>
</item>
<item>
<title>XML Tutorial</title>
<link>https://www.w3schools.com/xml</link>
<description>New XML tutorial on W3Schools</description>
</item>
</channel>

<channel>
<title>Google</title>
<link>https://www.google.com</link>
<description>Web search engine</description>
<item>
<title>Google News</title>
<link>https://news.google.com</link>
<description>New RSS tutorial on W3Schools</description>
</item>
<item>
<title>Amazon</title>
<link>https://www.amazon.com</link>
<description>New XML tutorial on W3Schools</description>
</item>
</channel>

</rss>


I duplicated simply channel tags by my design. My desired output is:

Code: Select all

channel_name_first
     item1
     ...
     itemn

channel_name_second
     item1
     ...
     itemn


I don't know how correct my data for Awasu here.

b) I'm still looking good way to print UTF in Windows from Python to console, because I have output in Awasu channel wizard with generated RSS and error:

Code: Select all

XML parse failed (4:L39:C49): not well-formed (invalid token)


I hope now is more clear to you what I am asking about :)

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sun Jul 30, 2017 11:40 am

awasu.user wrote:How format output for Awasu to detect multi channel in one script

You can't put more than 1 channel in an RSS file. If you want 5 different channels, you need 5 different "files". They can be generated by 1 script, but you need some way to tell the script what channel you want it output i.e. pass it a parameter.

It's like you can have 1 URL generate lots of different HTML pages e.g. myserver.com/page.php?id=1, myserver.com/page.php?id=2, etc. There's just one PHP script (page.php), and you pass it a parameter (id) telling it what exactly you want.

awasu.user wrote:I'm still looking good way to print UTF in Windows from Python to console

Look at the XML where the error is (L39:C49 = line 39, column 49). It could be something else e.g. Microsoft's stupid "smart quotes", an un-escaped & or <.

awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Sun Jul 30, 2017 5:46 pm

OK, I understand URL params very well, but if I understand you sugest solution:

1. Create New Channel
2. For each channel set:
c:\awasu_plg.py with options:

c:\awasu_plg.py -opt-one
c:\awasu_plg.py -opt-two

and read settings from INI based on option. In my scenario is ~170 dynamic calculated channels with changing settings. I'm looking for other solution how send from script information in style:

first channel finish - get data from here to Awasu
n channel finish - get data from here to Awasu
end of the script execution

support wrote:
awasu.user wrote:How format output for Awasu to detect multi channel in one script

Look at the XML where the error is (L39:C49 = line 39, column 49). It could be something else e.g. Microsoft's stupid "smart quotes", an un-escaped & or <.


I use in generation code between tags:

Code: Select all

 <![CDATA[  some text  ]]>


and it's still not works...


Return to “Awasu - Extensions”

Who is online

Users browsing this forum: No registered users and 2 guests