pushing last changes for 0.3 version
[stockthis] / stockthis.py
index c2a8b01..647e077 100644 (file)
@@ -38,7 +38,7 @@ osso_c = osso.Context("net.yerga.stockthis", "0.3", False)
 #detect if is ran locally or not
 runningpath = sys.path[0]
 
-if '/usr/share' in runningpath:
+if '/opt/' in runningpath:
     runninglocally = False
 else:
     runninglocally = True
@@ -48,7 +48,6 @@ HOME = os.path.expanduser("~")
 settingsdb, imgdir, configdir, logfile = \
     settings.define_paths(runninglocally, HOME)
 
-
 logger = logging.getLogger('st')
 logging.basicConfig(filename=logfile,level=logging.ERROR, filemode='w')
 
@@ -113,6 +112,10 @@ class StocksPy:
         self.window.add(vbox)
         self.window.show_all()
 
+        self.show_info_banner(self.window,
+            ("StockThis uses your network connection to get data.\n"
+            "Be aware of the high costs that your network provider may apply."))
+
     def create_menu(self, window):
         menu = hildon.AppMenu()
         window.set_app_menu(menu)
@@ -132,7 +135,7 @@ class StocksPy:
 
         window = hildon.StackableWindow()
         self.create_menu(window)
-        window.set_title("StockThis - " + inmodel[path][1])
+        window.set_title(inmodel[path][1])
 
         vbox = gtk.VBox()
         toolbar = self.main_toolbar(False, False, None, '', '', False)
@@ -213,7 +216,7 @@ class StocksPy:
 
         win = hildon.StackableWindow()
         self.create_menu(win)
-        win.set_title("StockThis - Quotes View - " + quote[1])
+        win.set_title(quote[1])
 
         vbox = gtk.VBox()
 
@@ -381,7 +384,7 @@ class StocksPy:
                     shares = item[2]
             return shares
         except:
-            logger.exception("Getting shares from symbol")
+            logger.exception("Getting shares from symbol: %s" % symbol)
             return shares
 
     def add_to_portfolio(self, widget, button, symbol, name):
@@ -404,7 +407,7 @@ class StocksPy:
 
             self.show_info_banner(widget, "Added to portfolio")
         except:
-            logger.exception("Adding to portfolio")
+            logger.exception("Adding to portfolio: %s, %s" % (symbol, name))
             self.show_info_banner(widget, "Error adding to portfolio")
 
 
@@ -430,7 +433,7 @@ class StocksPy:
         try:
             data = yt.get_all(symbol)
         except:
-            logger.exception("Getting data from Yahoo")
+            logger.exception("Getting data from Yahoo: %s" % symbol)
             data = {'price': 'N/A', 'change': 'N/A', 'volume':'N/A',
                     '52_week_high': 'N/A', '52_week_low': 'N/A'}
             ltitle.set_markup('<b><big>Failed to get data</big></b>')
@@ -483,7 +486,7 @@ class StocksPy:
     def show_graph_view(self, widget, symbol, name):
         win = hildon.StackableWindow()
         self.create_menu(win)
-        win.set_title("StockThis - Graph View - " + name)
+        win.set_title(name)
 
         vbox = gtk.VBox()
         toolbar = self.main_toolbar(False, True, None, '', '', False)
@@ -598,7 +601,7 @@ class StocksPy:
             self.graph.set_from_pixbuf(pbuf)
             winprogind(win, 0)
         except:
-            logger.exception("Getting graph data")
+            logger.exception("Getting graph data: %s" % url)
             winprogind(win, 0)
             self.graphs_title.set_label('Failed to get data')
             self.graph.destroy()
@@ -694,39 +697,38 @@ class StocksPy:
         if allnames == []:
             for market in marketdata.eunames:
                 for company in market:
-                    if not company in allnames:
-                        allnames.append(company)
+                    allnames.append(company)
 
             for market in marketdata.omnames:
                 for company in market:
-                    if not company in allnames:
-                        allnames.append(company)
+                    allnames.append(company)
 
             for market in marketdata.usnames:
                 for company in market:
-                    if not company in allnames:
-                        allnames.append(company)
+                    allnames.append(company)
 
         if allsymbols == []:
             for market in marketdata.eusymbols:
                 for company in market:
-                    if not company in allsymbols:
-                        allsymbols.append(company)
+                    allsymbols.append(company)
 
             for market in marketdata.omsymbols:
                 for company in market:
-                    if not company in allsymbols:
-                        allsymbols.append(company)
+                    allsymbols.append(company)
 
             for market in marketdata.ussymbols:
                 for company in market:
-                    if not company in allsymbols:
-                        allsymbols.append(company)
+                    allsymbols.append(company)
 
         new_model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
         for i in range(len(allnames)):
             if text.lower() in allnames[i].lower():
                 niter = new_model.append()
+                #print allsymbols[i], allnames[i]
+                #FIXME: repeated companies in the results list
+                #print if allnames[i]
+                #for j in new_model:
+                #    if j[1] == allnames[i]:
                 new_model.set(niter, 0, allsymbols[i], 1, allnames[i])
 
         if len(new_model) == 0:
@@ -745,7 +747,7 @@ class StocksPy:
     def show_search_screen(self, model, text):
         window = hildon.StackableWindow()
         self.create_menu(window)
-        window.set_title("StockThis - Search for " + text)
+        window.set_title("Search for " + text)
 
         vbox = gtk.VBox()
         toolbar = self.main_toolbar(False, False, None, '', '', False)
@@ -780,7 +782,7 @@ class StocksPy:
 
         win = hildon.StackableWindow()
         self.create_menu(win)
-        win.set_title("StockThis - Portfolio")
+        win.set_title("Portfolio")
 
         vbox = gtk.VBox()
 
@@ -935,7 +937,7 @@ class StocksPy:
             price = yt.get_price(symbol)
             return price
         except:
-            logger.exception("Getting price from Yahoo")
+            logger.exception("Getting price from Yahoo: %s" % symbol)
             return "N/A"
 
     def _create_portfolio_model(self, data):
@@ -1065,7 +1067,7 @@ class About:
         elif action == "vote":
             url = "http://maemo.org/downloads/product/stockthis"
 
-        iface.load_url(url)
+        iface.open_new_window(url)
 
     def show_info(self, widget, kind):
         if kind == 'license':