Added more log instructions. Detach photos_list in attachments
This commit is contained in:
parent
745a2a614e
commit
a46e7a51a0
@ -9,6 +9,7 @@ import configuration
|
|||||||
import player
|
import player
|
||||||
import posts
|
import posts
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import logging
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
from mysc.repeating_timer import RepeatingTimer
|
from mysc.repeating_timer import RepeatingTimer
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
@ -18,6 +19,8 @@ from wxUI.dialogs import search as searchDialogs
|
|||||||
from wxUI.dialogs import timeline
|
from wxUI.dialogs import timeline
|
||||||
from update import updater
|
from update import updater
|
||||||
|
|
||||||
|
log = logging.getLogger("controller.main")
|
||||||
|
|
||||||
class Controller(object):
|
class Controller(object):
|
||||||
|
|
||||||
def search(self, tab_name):
|
def search(self, tab_name):
|
||||||
@ -35,9 +38,11 @@ class Controller(object):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Controller, self).__init__()
|
super(Controller, self).__init__()
|
||||||
|
log.debug("Starting main controller...")
|
||||||
self.buffers = []
|
self.buffers = []
|
||||||
player.setup()
|
player.setup()
|
||||||
self.window = mainWindow.mainWindow()
|
self.window = mainWindow.mainWindow()
|
||||||
|
log.debug("Main window created")
|
||||||
self.window.change_status(_(u"Ready"))
|
self.window.change_status(_(u"Ready"))
|
||||||
self.session = session.sessions[session.sessions.keys()[0]]
|
self.session = session.sessions[session.sessions.keys()[0]]
|
||||||
self.create_controls()
|
self.create_controls()
|
||||||
@ -46,6 +51,7 @@ class Controller(object):
|
|||||||
call_threaded(updater.do_update)
|
call_threaded(updater.do_update)
|
||||||
|
|
||||||
def create_controls(self):
|
def create_controls(self):
|
||||||
|
log.debug("Creating controls for the window...")
|
||||||
posts_ = buffers.empty(parent=self.window.tb, name="posts")
|
posts_ = buffers.empty(parent=self.window.tb, name="posts")
|
||||||
self.buffers.append(posts_)
|
self.buffers.append(posts_)
|
||||||
self.window.add_buffer(posts_.tab, _(u"Posts"))
|
self.window.add_buffer(posts_.tab, _(u"Posts"))
|
||||||
@ -74,6 +80,7 @@ class Controller(object):
|
|||||||
self.window.add_buffer(timelines.tab, _(u"Timelines"))
|
self.window.add_buffer(timelines.tab, _(u"Timelines"))
|
||||||
|
|
||||||
def connect_events(self):
|
def connect_events(self):
|
||||||
|
log.debug("Connecting events to responses...")
|
||||||
pub.subscribe(self.in_post, "posted")
|
pub.subscribe(self.in_post, "posted")
|
||||||
pub.subscribe(self.download, "download-file")
|
pub.subscribe(self.download, "download-file")
|
||||||
pub.subscribe(self.play_audio, "play-audio")
|
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)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline)
|
||||||
|
|
||||||
def disconnect_events(self):
|
def disconnect_events(self):
|
||||||
|
log.debug("Disconnecting some events...")
|
||||||
pub.unsubscribe(self.in_post, "posted")
|
pub.unsubscribe(self.in_post, "posted")
|
||||||
pub.unsubscribe(self.download, "download-file")
|
pub.unsubscribe(self.download, "download-file")
|
||||||
pub.unsubscribe(self.play_audio, "play-audio")
|
pub.unsubscribe(self.play_audio, "play-audio")
|
||||||
@ -116,12 +124,14 @@ class Controller(object):
|
|||||||
buffer.get_items()
|
buffer.get_items()
|
||||||
|
|
||||||
def update_all_buffers(self):
|
def update_all_buffers(self):
|
||||||
|
log.debug("Updating buffers...")
|
||||||
for i in self.buffers:
|
for i in self.buffers:
|
||||||
if hasattr(i, "get_items"):
|
if hasattr(i, "get_items"):
|
||||||
i.get_items()
|
i.get_items()
|
||||||
print "executed for %s" % (i.name)
|
log.debug(u"Updated %s" % (i.name))
|
||||||
|
|
||||||
def download(self, url, filename):
|
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)
|
call_threaded(utils.download_file, url, filename, self.window)
|
||||||
|
|
||||||
def play_audio(self, audio_object):
|
def play_audio(self, audio_object):
|
||||||
@ -137,6 +147,7 @@ class Controller(object):
|
|||||||
p.dialog.Destroy()
|
p.dialog.Destroy()
|
||||||
|
|
||||||
def exit(self, *args, **kwargs):
|
def exit(self, *args, **kwargs):
|
||||||
|
log.debug("Receibed an exit signal. closing...")
|
||||||
self.disconnect_events()
|
self.disconnect_events()
|
||||||
self.window.Destroy()
|
self.window.Destroy()
|
||||||
wx.GetApp().ExitMainLoop()
|
wx.GetApp().ExitMainLoop()
|
||||||
|
@ -8,6 +8,7 @@ import output
|
|||||||
import wx
|
import wx
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import utils
|
import utils
|
||||||
|
import logging
|
||||||
from sessionmanager import session # We'll use some functions from there
|
from sessionmanager import session # We'll use some functions from there
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
from wxUI.dialogs import postDialogs, urlList
|
from wxUI.dialogs import postDialogs, urlList
|
||||||
@ -15,6 +16,8 @@ from extra import SpellChecker, translator
|
|||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
from wxUI import menus
|
from wxUI import menus
|
||||||
|
|
||||||
|
log = logging.getLogger("controller.post")
|
||||||
|
|
||||||
def get_user(id, profiles):
|
def get_user(id, profiles):
|
||||||
""" Returns an user name and last name based in the id receibed."""
|
""" Returns an user name and last name based in the id receibed."""
|
||||||
for i in profiles:
|
for i in profiles:
|
||||||
@ -121,6 +124,9 @@ class postController(object):
|
|||||||
attachments = []
|
attachments = []
|
||||||
if post.has_key("attachments"):
|
if post.has_key("attachments"):
|
||||||
for i in post["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))
|
attachments.append(add_attachment(i))
|
||||||
self.attachments.append(i)
|
self.attachments.append(i)
|
||||||
if len(self.attachments) > 0:
|
if len(self.attachments) > 0:
|
||||||
@ -302,6 +308,8 @@ class postController(object):
|
|||||||
webbrowser.open_new_tab(url)
|
webbrowser.open_new_tab(url)
|
||||||
else:
|
else:
|
||||||
print attachment["photo"].keys()
|
print attachment["photo"].keys()
|
||||||
|
else:
|
||||||
|
log.debug("Unhandled attachment: %r" % (attachment,))
|
||||||
|
|
||||||
class comment(object):
|
class comment(object):
|
||||||
def __init__(self, session, comment_object):
|
def __init__(self, session, comment_object):
|
||||||
|
Loading…
Reference in New Issue
Block a user