Added more log instructions. Detach photos_list in attachments

This commit is contained in:
Manuel Cortez 2016-05-12 17:44:53 -05:00
parent 745a2a614e
commit a46e7a51a0
2 changed files with 20 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import configuration
import player
import posts
import webbrowser
import logging
from pubsub import pub
from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded
@ -18,6 +19,8 @@ from wxUI.dialogs import search as searchDialogs
from wxUI.dialogs import timeline
from update import updater
log = logging.getLogger("controller.main")
class Controller(object):
def search(self, tab_name):
@ -35,9 +38,11 @@ class Controller(object):
def __init__(self):
super(Controller, self).__init__()
log.debug("Starting main controller...")
self.buffers = []
player.setup()
self.window = mainWindow.mainWindow()
log.debug("Main window created")
self.window.change_status(_(u"Ready"))
self.session = session.sessions[session.sessions.keys()[0]]
self.create_controls()
@ -46,6 +51,7 @@ class Controller(object):
call_threaded(updater.do_update)
def create_controls(self):
log.debug("Creating controls for the window...")
posts_ = buffers.empty(parent=self.window.tb, name="posts")
self.buffers.append(posts_)
self.window.add_buffer(posts_.tab, _(u"Posts"))
@ -74,6 +80,7 @@ class Controller(object):
self.window.add_buffer(timelines.tab, _(u"Timelines"))
def connect_events(self):
log.debug("Connecting events to responses...")
pub.subscribe(self.in_post, "posted")
pub.subscribe(self.download, "download-file")
pub.subscribe(self.play_audio, "play-audio")
@ -92,6 +99,7 @@ class Controller(object):
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline)
def disconnect_events(self):
log.debug("Disconnecting some events...")
pub.unsubscribe(self.in_post, "posted")
pub.unsubscribe(self.download, "download-file")
pub.unsubscribe(self.play_audio, "play-audio")
@ -116,12 +124,14 @@ class Controller(object):
buffer.get_items()
def update_all_buffers(self):
log.debug("Updating buffers...")
for i in self.buffers:
if hasattr(i, "get_items"):
i.get_items()
print "executed for %s" % (i.name)
log.debug(u"Updated %s" % (i.name))
def download(self, url, filename):
log.debug(u"downloading %s URL to %s filename" % (url, filename,))
call_threaded(utils.download_file, url, filename, self.window)
def play_audio(self, audio_object):
@ -137,6 +147,7 @@ class Controller(object):
p.dialog.Destroy()
def exit(self, *args, **kwargs):
log.debug("Receibed an exit signal. closing...")
self.disconnect_events()
self.window.Destroy()
wx.GetApp().ExitMainLoop()

View File

@ -8,6 +8,7 @@ import output
import wx
import webbrowser
import utils
import logging
from sessionmanager import session # We'll use some functions from there
from pubsub import pub
from wxUI.dialogs import postDialogs, urlList
@ -15,6 +16,8 @@ from extra import SpellChecker, translator
from mysc.thread_utils import call_threaded
from wxUI import menus
log = logging.getLogger("controller.post")
def get_user(id, profiles):
""" Returns an user name and last name based in the id receibed."""
for i in profiles:
@ -121,6 +124,9 @@ class postController(object):
attachments = []
if post.has_key("attachments"):
for i in post["attachments"]:
# We don't need the photos_list attachment, so skip it.
if i["type"] == "photos_list":
continue
attachments.append(add_attachment(i))
self.attachments.append(i)
if len(self.attachments) > 0:
@ -302,6 +308,8 @@ class postController(object):
webbrowser.open_new_tab(url)
else:
print attachment["photo"].keys()
else:
log.debug("Unhandled attachment: %r" % (attachment,))
class comment(object):
def __init__(self, session, comment_object):