Merge branch 'next-gen' of https://github.com/manuelcortez/TWBlue into next-gen

This commit is contained in:
Manuel Cortez 2015-04-14 08:51:33 -05:00
commit 7cdda6806b
8 changed files with 74 additions and 60 deletions

View File

@ -4,11 +4,11 @@ TWBlue - Next generation
Note Note
====== ======
Please note that this branch is a new generation of TWBlue, so the code is been written using the MVC design pattern and it is very unstable. This code does not works properly and it is not recommended its use, only you use this code for testing purposes. You may find some huge bugs, because we're written most of the source code from scratch. Please note that this branch is a new generation of TWBlue. The code has been rewritten using the MVC design pattern. It is very unstable. This code may not work properly and it's use is not recommended. Only use for testing purposes.
TWBlue, an accessible, open source and multiplatform twitter application. TWBlue, an accessible, open source and multiplatform twitter application.
TW Blue is an app designed to use Twitter simply and efficiently while using minimal system resources.
TW Blue is an app designed to use Twitter in a simple and fast way and avoiding, as far as possible, the consumtion of excessive resources of the machine where its running. With this app youll have access to twitter features such as: With this app youll have access to twitter features such as:
* Create, reply to, retweet and delete tweets, * Create, reply to, retweet and delete tweets,
* Add and remove tweets from favourites, * Add and remove tweets from favourites,
@ -16,11 +16,11 @@ TW Blue is an app designed to use Twitter in a simple and fast way and avoiding,
* See your friends and followers, * See your friends and followers,
* Follow, unfollow, block and report users as spam, * Follow, unfollow, block and report users as spam,
* Open a users timeline, which will allow you to get that users tweets separately, * Open a users timeline, which will allow you to get that users tweets separately,
* Open URL addresses when attached to a tweet or direct message, * Open URLs when attached to a tweet or direct message,
* Play various file and URL types which contain audio * Play audio tweets
* and more! * and more!
See the [TWBlue's webpage](http://twblue.es) for more details. See [TWBlue's webpage](http://twblue.es) for more details.
## Using TWBlue from sources ## Using TWBlue from sources
@ -92,15 +92,15 @@ This dependency has been built using pure basic 4.61. Its source can be found at
### Running TW Blue from source ### Running TW Blue from source
Now that you have installed all these packages, you can run TW Blue from source using a command prompt. Navigate to the src directory into the repo, and type the following command: Now that you have installed all these packages, you can run TW Blue from source using a command prompt. Navigate to the repo's src directory, and type the following command:
python main.py python main.py
If necesary, change the first part of the command to reflect where is your python executable. You can run TW Blue using python x86 and x64 If necessary, change the first part of the command to reflect the location of your python executable. You can run TW Blue using python x86 and x64
### Building a binary version ### Building a binary version
A binary version doesn't need python and the other dependencies to run, it's the same version that you will find in TW Blue website if you download the zip files. A binary version doesn't need python and the other dependencies to run, it's the same version that you will find on the TW Blue website if you download the zip files.
To build it, run the following command from the src folder: To build it, run the following command from the src folder:
@ -110,4 +110,4 @@ To build it, run the following command from the src folder:
### How to generate a translation template ### How to generate a translation template
You must run the gen_pot.bat file, located in the tools directory. Your python installation should be in your path environment variable. The pot file will appear in the tools directory too. Run the gen_pot.bat file, located in the tools directory. Your python installation must be in your path environment variable. The pot file will appear in the tools directory.

View File

@ -1,4 +1,5 @@
Manuel E. Cortéz Manuel E. Cortéz
Bill Dengler
Johana Hidrobo Johana Hidrobo
Marcelo Sosa Marcelo Sosa
Isabel del Castillo Isabel del Castillo

View File

@ -10,7 +10,7 @@ else:
author = u"Manuel Cortéz" author = u"Manuel Cortéz"
authorEmail = "manuel@manuelcortez.net" authorEmail = "manuel@manuelcortez.net"
copyright = u"copyright (C) 2013-2015, Manuel cortéz" copyright = u"copyright (C) 2013-2015, Manuel cortéz"
description = u"TW Blue is an app designed to use Twitter in a simple and fast way and avoiding, as far as possible, the consumtion of excessive resources of the machine where its running. With this app youll have access to most twitter features." description = u"TW Blue is an app designed to use Twitter simply and efficiently while using minimal system resources. This app provides access to most Twitter features."
translators = [u"Bryner Villalobos (English)", u"Mohammed Al Shara (Arabic)", u"Joan Rabat, Juan Carlos Rivilla (Catalan)", u"Manuel cortéz (Spanish)", u"Sukil Etxenike Arizaleta (Basque)", u"Jani Kinnunen (finnish)", u"Rémy Ruiz (French)", u"Alba Quinteiro (Galician)", u"Steffen Schultz (German)", u"Robert Osztolykan (Hungarian)", u"Paweł Masarczyk (Polish)", u"Odenilton Júnior Santos (Portuguese)", u"Alexander Jaszyn (Russian)", u"Burak (Turkish)"] translators = [u"Bryner Villalobos, Bill Dengler (English)", u"Mohammed Al Shara (Arabic)", u"Joan Rabat, Juan Carlos Rivilla (Catalan)", u"Manuel cortéz (Spanish)", u"Sukil Etxenike Arizaleta (Basque)", u"Jani Kinnunen (finnish)", u"Rémy Ruiz (French)", u"Alba Quinteiro (Galician)", u"Steffen Schultz (German)", u"Robert Osztolykan (Hungarian)", u"Paweł Masarczyk (Polish)", u"Odenilton Júnior Santos (Portuguese)", u"Alexander Jaszyn (Russian)", u"Burak (Turkish)"]
url = u"http://twblue.es" url = u"http://twblue.es"
report_bugs_url = "http://twblue.es/bugs/api/soap/mantisconnect.php?wsdl" report_bugs_url = "http://twblue.es/bugs/api/soap/mantisconnect.php?wsdl"

View File

@ -6,9 +6,9 @@ log = logging.getLogger("commandlineLauncher")
parser = argparse.ArgumentParser(description="TW Blue command line launcher") parser = argparse.ArgumentParser(description="TW Blue command line launcher")
group = parser.add_mutually_exclusive_group() group = parser.add_mutually_exclusive_group()
group.add_argument("-p", "--portable", help="Use TW Blue as a portable aplication", action="store_true", default=True) group.add_argument("-p", "--portable", help="Use TW Blue as a portable application.", action="store_true", default=True)
group.add_argument("-i", "--installed", help="Use TW Blue as an installed application. Config files will be saved on the user data directory", action="store_true") group.add_argument("-i", "--installed", help="Use TW Blue as an installed application. Config files will be saved in the user data directory", action="store_true")
parser.add_argument("-d", "--data-directory", action="store", dest="directory", help="Specifies the directory where TW Blue saves the data files") parser.add_argument("-d", "--data-directory", action="store", dest="directory", help="Specifies the directory where TW Blue saves userdata.")
args = parser.parse_args() args = parser.parse_args()
log.debug("Starting TWBlue with the following arguments: installed = %s, portable = %s and directory = %s" % (args.installed, args.portable, args.directory)) log.debug("Starting TWBlue with the following arguments: installed = %s, portable = %s and directory = %s" % (args.installed, args.portable, args.directory))
if args.installed == True: paths.mode = "installed" if args.installed == True: paths.mode = "installed"

View File

@ -0,0 +1,11 @@
#Reverse sort, by Bill Dengler <codeofdusk@gmail.com> for use in TWBlue http://twblue.es
def invert_tuples(t):
"Invert a list of tuples, so that the 0th element becomes the -1th, and the -1th becomes the 0th."
res=[]
for i in t:
res.append(i[::-1])
return res
def reverse_sort(t):
"Sorts a list of tuples/lists by their last elements, not their first."
return invert_tuples(sorted(invert_tuples(t)))

View File

@ -4,6 +4,7 @@ import widgetUtils
import os import os
import paths import paths
import logging import logging
import reverse_sort
log = logging.getLogger("extra.SoundsTutorial.soundsTutorial") log = logging.getLogger("extra.SoundsTutorial.soundsTutorial")
import soundsTutorial_constants import soundsTutorial_constants
if platform.system() == "Windows": if platform.system() == "Windows":
@ -22,6 +23,8 @@ class soundsTutorial(object):
self.files = [] self.files = []
log.debug("Searching sound files...") log.debug("Searching sound files...")
[self.files.append(i[0]) for i in soundsTutorial_constants.actions] [self.files.append(i[0]) for i in soundsTutorial_constants.actions]
log.debug("Alphabetizing actions...")
actions=reverse_sort.reverse_sort(actions)
log.debug("Creating dialog...") log.debug("Creating dialog...")
self.dialog = UI.soundsTutorialDialog(self.actions) self.dialog = UI.soundsTutorialDialog(self.actions)
widgetUtils.connect_event(self.dialog.play, widgetUtils.BUTTON_PRESSED, self.on_play) widgetUtils.connect_event(self.dialog.play, widgetUtils.BUTTON_PRESSED, self.on_play)

View File

@ -1,25 +1,25 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
actions = [ ("audio", _(u"The tweet may contain a playable audio")), actions = [ ("audio", _(u"Audio tweet.")),
("create_timeline", _(u"A timeline has been created")), ("create_timeline", _(u"User-defined buffer created.")),
("delete_timeline", _(u"A timeline has been deleted")), ("delete_timeline", _(u"User-defined buffer destroied.")),
("dm_received", _(u"You've received a direct message")), ("dm_received", _(u"Direct message received.")),
("dm_sent", _(u"You've sent a direct message")), ("dm_sent", _(u"Direct message sent.")),
("error", _(u"A bug has happened")), ("error", _(u"Error.")),
("favourite", _(u"You've added a tweet to your favourites")), ("favourite", _(u"You favorited a tweet.")),
("favourites_timeline_updated", _(u"Someone's favourites have been updated")), ("favourites_timeline_updated", _(u"Someone's favourites have been updated.")),
("geo", _(u"The tweet has coordinates to determine its location")), ("geo", _(u"Geotweet.")),
("limit", _(u"There are no more tweets to read")), ("limit", _(u"Boundary reached.")),
("list_tweet", _(u"A list has a new tweet")), ("list_tweet", _(u"List updated.")),
("max_length", _(u"You can't add any more characters on the tweet")), ("max_length", _(u"Too many characters.")),
("mention_received", _(u"You've been mentioned ")), ("mention_received", _(u"You've been mentioned.")),
("new_event", _(u"A new event has happened")), ("new_event", _(u"New event.")),
("ready", _(u"TW Blue is ready ")), ("ready", _(u"Application is ready.")),
("reply_send", _(u"You've replied")), ("reply_send", _(u"You've replied publicly.")),
("retweet_send", _(u"You've retweeted")), ("retweet_send", _(u"You've retweeted.")),
("search_updated", _(u"A search has been updated")), ("search_updated", _(u"A search buffer has been updated.")),
("tweet_received", _(u"There's a new tweet in the main buffer")), ("tweet_received", _(u"New tweet in home buffer.")),
("tweet_send", _(u"You've sent a tweet")), ("tweet_send", _(u"You've sent a tweet.")),
("trends_updated", _(u"A trending topic buffer has been updated")), ("trends_updated", _(u"A trending topic buffer has been updated.")),
("tweet_timeline", _(u"There's a new tweet in a timeline")), ("tweet_timeline", _(u"New tweet in user-defined buffer.")),
("update_followers", _(u"You have a new follower")), ("update_followers", _(u"New follower.")),
("volume_changed", _(u"You've turned the volume up or down"))] ("volume_changed", _(u"Volume changed."))]

View File

@ -25,14 +25,14 @@ class Session(object):
def _require_login(fn): def _require_login(fn):
""" Decorator for checking if the user is logged (a twitter object has credentials) on twitter. """ Decorator for checking if the user is logged in(a twitter object has credentials) on twitter.
Some functions may need this to avoid make unneeded twitter API calls.""" Some functions may need this to avoid making unneeded twitter API calls."""
def f(self, *args, **kwargs): def f(self, *args, **kwargs):
if self.logged == True: if self.logged == True:
fn(self, *args, **kwargs) fn(self, *args, **kwargs)
else: else:
raise Exceptions.NotLoggedSessionError("You are not logged yet.") raise Exceptions.NotLoggedSessionError("You are not logged in yet.")
return f return f
def _require_configuration(fn): def _require_configuration(fn):
@ -48,10 +48,10 @@ class Session(object):
def order_buffer(self, name, data): def order_buffer(self, name, data):
""" Put the new items on the local database. """ Put the new items in the local database.
name str: The name for the buffer stored in the dictionary. name str: The name for the buffer stored in the dictionary.
data list: A list with tweets. data list: A list with tweets.
returns the number of items that has been added in this execution""" returns the number of items that have been added in this execution"""
num = 0 num = 0
if self.db.has_key(name) == False: if self.db.has_key(name) == False:
@ -68,7 +68,7 @@ class Session(object):
""" Put the new items on the local database. Useful for cursored buffers (followers, friends, users of a list and searches) """ Put the new items on the local database. Useful for cursored buffers (followers, friends, users of a list and searches)
name str: The name for the buffer stored in the dictionary. name str: The name for the buffer stored in the dictionary.
data list: A list with items and some information about cursors. data list: A list with items and some information about cursors.
returns the number of items that has been added in this execution""" returns the number of items that have been added in this execution"""
num = 0 num = 0
if self.db.has_key(name) == False: if self.db.has_key(name) == False:
@ -118,7 +118,7 @@ class Session(object):
@_require_configuration @_require_configuration
def login(self, verify_credentials=True): def login(self, verify_credentials=True):
""" Login in to twitter using credentials from settings. """ Log into twitter using credentials from settings.
if the user account isn't authorised, it needs to call self.authorise() before login.""" if the user account isn't authorised, it needs to call self.authorise() before login."""
if self.settings["twitter"]["user_key"] != None and self.settings["twitter"]["user_secret"] != None: if self.settings["twitter"]["user_key"] != None and self.settings["twitter"]["user_secret"] != None:
@ -134,7 +134,7 @@ class Session(object):
@_require_configuration @_require_configuration
def authorise(self): def authorise(self):
""" Authorises a Twitter account. This function needs to be called for each new session, after of self.get_configuration() and before of self.login()""" """ Authorises a Twitter account. This function needs to be called for each new session, after self.get_configuration() and before self.login()"""
if self.logged == True: if self.logged == True:
raise Exceptions.AlreadyAuthorisedError("The authorisation process is not needed at this time.") raise Exceptions.AlreadyAuthorisedError("The authorisation process is not needed at this time.")
@ -153,14 +153,14 @@ class Session(object):
def api_call(self, call_name, action="", _sound=None, report_success=False, report_failure=True, preexec_message="", *args, **kwargs): def api_call(self, call_name, action="", _sound=None, report_success=False, report_failure=True, preexec_message="", *args, **kwargs):
""" Make a call to the Twitter API. If there is a connectionError or another exception not related to Twitter, It will call to the method at least 25 times, waiting a while between calls. Useful for post methods. """ Make a call to the Twitter API. If there is a connectionError or another exception not related to Twitter, It will call the method again at least 25 times, waiting a while between calls. Useful for post methods.
If twitter returns an error, it will not call anymore the method. If twitter returns an error, it will not call the method anymore.
call_name str: The method to call call_name str: The method to call
action str: The thing what you are doing on twitter, it will be reported to the user if report_success is set to True. action str: What you are doing on twitter, it will be reported to the user if report_success is set to True.
for example "following @tw_blue2" will be reported as "following @tw_blue2 succeeded". for example "following @tw_blue2" will be reported as "following @tw_blue2 succeeded".
_sound str: a sound to play if the call is executed properly. _sound str: a sound to play if the call is executed properly.
report_success and report_failure bool: These are self explanatory. True or false. It's all. report_success and report_failure bool: These are self explanatory. True or False.
preexec_message str: A message to speak to the user while the call is doing the work, example: "try to follow to x user".""" preexec_message str: A message to speak to the user while the method is running, example: "trying to follow x user"."""
finished = False finished = False
tries = 0 tries = 0
@ -193,8 +193,8 @@ class Session(object):
@_require_login @_require_login
def get_favourites_timeline(self, name, *args, **kwargs): def get_favourites_timeline(self, name, *args, **kwargs):
""" Gets favourites for the authenticated user or a friend or follower or somewhat. """ Gets favourites for the authenticated user or a friend or follower.
name str: Name for store all in the database.""" name str: Name for storage in the database."""
tl = self.call_paged(self.twitter.twitter.get_favorites, *args, **kwargs) tl = self.call_paged(self.twitter.twitter.get_favorites, *args, **kwargs)
return self.order_buffer(name, tl) return self.order_buffer(name, tl)
@ -204,7 +204,7 @@ class Session(object):
""" Makes a call to the Twitter API methods several times. Useful for get methods. """ Makes a call to the Twitter API methods several times. Useful for get methods.
this function is needed for retrieving more than 200 items. this function is needed for retrieving more than 200 items.
update_function str: The function to call. This function must be child of self.twitter.twitter update_function str: The function to call. This function must be child of self.twitter.twitter
return a list with all items retrieved.""" returns a list with all items retrieved."""
max = int(self.settings["general"]["max_api_calls"])-1 max = int(self.settings["general"]["max_api_calls"])-1
results = [] results = []
@ -222,7 +222,6 @@ class Session(object):
def get_user_info(self): def get_user_info(self):
""" Retrieves some information required by TWBlue for setup.""" """ Retrieves some information required by TWBlue for setup."""
f = self.twitter.twitter.get_account_settings() f = self.twitter.twitter.get_account_settings()
sn = f["screen_name"] sn = f["screen_name"]
self.settings["twitter"]["user_name"] = sn self.settings["twitter"]["user_name"] = sn
@ -239,7 +238,7 @@ class Session(object):
@_require_login @_require_login
def get_lists(self): def get_lists(self):
""" Gets the lists that the user is suscribed.""" """ Gets the lists that the user is subscribed to and stores them in the database. Returns None."""
self.db["lists"] = self.twitter.twitter.show_lists(reverse=True) self.db["lists"] = self.twitter.twitter.show_lists(reverse=True)
@ -254,7 +253,7 @@ class Session(object):
def get_stream(self, name, function, *args, **kwargs): def get_stream(self, name, function, *args, **kwargs):
""" Retrieves the items for a regular stream. """ Retrieves the items for a regular stream.
name str: Name to save items on the database. name str: Name to save items to the database.
function str: A function to get the items.""" function str: A function to get the items."""
last_id = -1 last_id = -1
@ -272,11 +271,11 @@ class Session(object):
@_require_login @_require_login
def get_cursored_stream(self, name, function, items="users", *args, **kwargs): def get_cursored_stream(self, name, function, items="users", *args, **kwargs):
""" Gets items for API calls that requires using cursors to paginate the results. """ Gets items for API calls that require using cursors to paginate the results.
name str: Name to save it in the database. name str: Name to save it in the database.
function str: Function that provides the items. function str: Function that provides the items.
items: When the function returns the list with results, items will tell how the order function should be look. items: When the function returns the list with results, items will tell how the order function should be look.
for example get_followers_list returns a list and users are under list["users"], here the items should be point to "users".""" for example get_followers_list returns a list and users are under list["users"], here the items should point to "users"."""
items_ = [] items_ = []
try: try: