<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Mon May 20, 2013 5:14 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Mon May 20, 2013 5:14 pm</pubDate>
  <lastBuildDate>Mon May 20, 2013 5:14 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: Updating the desktop icon in python</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=95709#95709</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=21079'&gt;leke&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri Dec 17, 2010 12:22 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      &lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;nelz wrote:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;quote&quot;&gt;This is probably to do with the execution environment, when you run it from a terminal, you have sourced .bashrc.&lt;br /&gt;
&lt;br /&gt;
The trouble with os.system() is it just sends the command to the system and forgets about it, so you get no return codes or error messages, try using the subprocess module instead.&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;Thanks, I never knew about that. Just reading up on it now.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=95709#95709</comments>
                                        <author>leke</author>
                                        <pubDate>Fri Dec 17, 2010 12:22 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=95709#95709</guid>
                                      </item>
                                      <item>
                                        <title>Re: Updating the desktop icon in python</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=95707#95707</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=5'&gt;nelz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri Dec 17, 2010 9:42 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      This is probably to do with the execution environment, when you run it from a terminal, you have sourced .bashrc.&lt;br /&gt;
&lt;br /&gt;
The trouble with os.system() is it just sends the command to the system and forgets about it, so you get no return codes or error messages, try using the subprocess module instead.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=95707#95707</comments>
                                        <author>nelz</author>
                                        <pubDate>Fri Dec 17, 2010 9:42 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=95707#95707</guid>
                                      </item>
                                      <item>
                                        <title>Updating the desktop icon in python</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=95706#95706</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=21079'&gt;leke&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri Dec 17, 2010 9:03 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Hi, the following code works fine -- that is it creates the icon and support text in the same location as the python script, but doesn't update the desktop icon correctly. Specifically, this function doesn't seem to work. &lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;def update_icon_file&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cmd = &amp;quot;xdg-desktop-icon install --novendor /home/asdf/Desktop/test.desktop&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; os.system&amp;#40;cmd&amp;#41;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
If I run xdg-desktop-icon install --novendor /home/asdf/Desktop/test.desktop in the terminal though, it works fine.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;#!usr/bin/env python&lt;br /&gt;
# -*- coding&amp;#58; utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
import feedparser, os, re&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#### Update the icon on the desktop - Change test.desktop to the name of your icon file.&lt;br /&gt;
def update_icon_file&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cmd = &amp;quot;xdg-desktop-icon install --novendor /home/asdf/Desktop/test.desktop&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; os.system&amp;#40;cmd&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#### End.&lt;br /&gt;
&lt;br /&gt;
#### Store of details for icon config file&lt;br /&gt;
def config_file_succsess&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; success = '''#!/usr/bin/env xdg-open&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;#91;Desktop Entry&amp;#93;&lt;br /&gt;
Version=1.0&lt;br /&gt;
Name = &amp;#123;0&amp;#125;&lt;br /&gt;
GenericName = info icon&lt;br /&gt;
Comment = info icon created by http&amp;#58;//rebol.vlexo.net&lt;br /&gt;
Exec = python /home/asdf/Dev/python/info_icons/icon_weather.py&lt;br /&gt;
Terminal = false&lt;br /&gt;
Type = Application&lt;br /&gt;
Icon = &amp;#123;1&amp;#125;&lt;br /&gt;
Categories = Application&lt;br /&gt;
MimeType = image/jpeg;text/python;&lt;br /&gt;
StartupNotify = false&lt;br /&gt;
'''.format&amp;#40;rss_feed_summary + &amp;quot;\\n&amp;quot; + rss_feed_time, icon_image&amp;#41; # &amp;#123;0&amp;#125;, &amp;#123;1&amp;#125;, etc...&lt;br /&gt;
&amp;nbsp; &amp;nbsp; f = open&amp;#40;'/home/asdf/Dev/python/info_icons/test.desktop','w'&amp;#41; # need to find how to get ls of location of python script.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; f.write&amp;#40;success&amp;#41;&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; f.close&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; update_icon_file&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
def config_file_fail&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; failed = '''#!/usr/bin/env xdg-open&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;#91;Desktop Entry&amp;#93;&lt;br /&gt;
Version=1.0&lt;br /&gt;
Name = &amp;#123;0&amp;#125;&lt;br /&gt;
GenericName = info icon&lt;br /&gt;
Comment = info icon created by http&amp;#58;//rebol.vlexo.net&lt;br /&gt;
Exec = python /home/asdf/Dev/python/info_icons/icon_weather.py&lt;br /&gt;
Terminal = false&lt;br /&gt;
Type = Application&lt;br /&gt;
Icon = /home/asdf/Dev/python/info_icons/icons/icon-mystery.jpg&lt;br /&gt;
Categories = Application&lt;br /&gt;
MimeType = image/jpeg;text/python;&lt;br /&gt;
StartupNotify = false&lt;br /&gt;
'''.format&amp;#40;connect_error&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; f = open&amp;#40;'/home/asdf/Dev/python/info_icons/test.desktop','w'&amp;#41; # need to find how to get ls of location of python script.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; f.write&amp;#40;failed&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; f.close&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; update_icon_file&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#### End.&lt;br /&gt;
&lt;br /&gt;
#### Get some RSS data from server&lt;br /&gt;
def write_it&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; global rss_feed_summary, rss_feed_time, connect_error &lt;br /&gt;
&amp;nbsp; &amp;nbsp; try&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; df = feedparser.parse&amp;#40;'http&amp;#58;//www.rssweather.com/wx/fi/pirkkala/rss.php'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rss_feed_summary = str&amp;#40;df.entries&amp;#91;0&amp;#93;.summary&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rss_feed_time = str&amp;#40;df.entries&amp;#91;0&amp;#93;.updated&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; which_icon&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; config_file_succsess&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; except&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; connect_error = &amp;quot;Could not retrieve data from server.&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; config_file_fail&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def which_icon&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; global icon_image, s, temp&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Search for a word or number in string &amp;lt;line1&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; s = rss_feed_summary.lower&amp;#40;&amp;#41; # all lowercase&lt;br /&gt;
&amp;nbsp; &amp;nbsp; temp = s.split&amp;#40;&amp;#41; # split by space&lt;br /&gt;
&amp;nbsp; &amp;nbsp; temp = temp&amp;#91;0&amp;#93;&amp;#91;&amp;#58;-1&amp;#93; # trim the 'c' from temperature&lt;br /&gt;
&amp;nbsp; &amp;nbsp; temp = int&amp;#40;temp&amp;#41; # convert string to integer&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; if &amp;#40;&amp;quot;fog&amp;quot; or &amp;quot;mist&amp;quot;&amp;#41; in s&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-fog.jpg&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; elif &amp;quot;rain&amp;quot; in s&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if not &amp;quot;grains&amp;quot; in s&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-rain.jpg&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; elif &amp;quot;rain&amp;quot; in s&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if not &amp;quot;grains&amp;quot; in s&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-rain.jpg&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; elif &amp;#40;&amp;quot;wind&amp;quot; or &amp;quot;gale&amp;quot;&amp;#41; in s&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-wind&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; elif temp &amp;gt; 0&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if temp &amp;lt; 10&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-cold.jpg&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; elif temp &amp;lt; -25&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-hibernate.gif&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; elif temp &amp;lt; 0&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-winter.jpg&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; elif temp &amp;gt; 30&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-fire.jpg&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; elif temp &amp;gt; 20&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-summer.jpg&amp;quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else&amp;#58; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; icon_image = &amp;quot;/home/asdf/Dev/python/info_icons/icons/icon-mystery.jpg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
write_it&amp;#40;&amp;#41;&lt;br /&gt;
#### End.&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=95706#95706</comments>
                                        <author>leke</author>
                                        <pubDate>Fri Dec 17, 2010 9:03 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=95706#95706</guid>
                                      </item></channel></rss>