# built documents.
#
# The short X.Y version.
-version = '0.5.3'
+version = '0.5.4'
# The full version, including alpha/beta/rc tags.
-release = '0.5.3'
+release = '0.5.4'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
return res
- def semaphore_store(self, flag, pause):
+ def semaphore_store(self, lock, pause):
"""
- Store semaphore flag
+ Store semaphore lock
"""
Session = sessionmaker(bind=self.engine)
session = Session()
- th = Semaphore(flag, pause)
+ th = Semaphore(lock, pause)
session.add(th)
session.commit()
- def semaphore_update_flag(self, flag):
+ def semaphore_update_lock(self, lock):
"""
- Update semaphore flag
+ Update semaphore lock
"""
Session = sessionmaker(bind=self.engine)
session = Session()
res = session.query(Semaphore).all()
for r in res:
- r.flag = flag
+ r.lock = lock
session.commit()
session.commit()
- def semaphore_query_flag(self):
+ def semaphore_query_lock(self):
"""
- Query semaphore flag
+ Query semaphore lock
"""
Session = sessionmaker(bind=self.engine)
session = Session()
res = session.query(Semaphore).all()
- return res[0].flag
+ return res[0].lock
def semaphore_query_pause(self):
Draw the rainbow
"""
+ # Check the semaphore lock (stream process only)
+ if check_semaphore:
+ if db.semaphore_query_pause():
+ return
+ while db.semaphore_query_lock():
+ time.sleep(0.5)
+
+ # Check config and theme
check_config()
reload_theme(c['THEME'])
+
# Retrieve tweet
tid = t['id']
text = t['text']
printNicely(red('Wrong format in config.'))
return
- # Check the semaphore lock (stream process only)
- if check_semaphore:
- if db.semaphore_query_pause():
- return
- while db.semaphore_query_flag():
- time.sleep(0.5)
-
# Draw
printNicely(formater)
printNicely(red('Sorry, image link is broken'))
-def print_message(m):
+def print_message(m, check_semaphore=False):
"""
Print direct message
"""
+
+ # Check the semaphore lock (stream process only)
+ if check_semaphore:
+ if db.semaphore_query_pause():
+ return
+ while db.semaphore_query_lock():
+ time.sleep(0.5)
+
+ # Retrieve message
sender_screen_name = '@' + m['sender_screen_name']
sender_name = m['sender']['name']
text = unescape(m['text'])
if c['IMAGE_ON_TERM']:
try:
response = requests.get(profile_image_url)
- image_to_display(BytesIO(response.content), 2, 20)
+ image_to_display(BytesIO(response.content))
except:
pass
else:
g['cmd'] = cmd
try:
# Lock the semaphore
- db.semaphore_update_flag(True)
+ db.semaphore_update_lock(True)
# Save cmd to global variable and call process
g['stuff'] = ' '.join(line.split()[1:])
# Process the command
else:
g['prefix'] = True
# Release the semaphore lock
- db.semaphore_update_flag(False)
+ db.semaphore_update_lock(False)
except Exception:
printNicely(red('OMG something is wrong with Twitter right now.'))
ig=args.ignore,
)
elif tweet.get('direct_message'):
- print_message(tweet['direct_message'])
+ print_message(tweet['direct_message'],check_semaphore=True)
except TwitterHTTPError:
printNicely('')
printNicely(
__tablename__ = "semaphore"
semaphore_id = Column(Integer, primary_key=True)
- flag = Column(Boolean)
+ lock = Column(Boolean)
pause = Column(Boolean)
- def __init__(self, flag, pause):
- self.flag = flag
+ def __init__(self, lock, pause):
+ self.lock = lock
self.pause = pause
import os, os.path, sys
# Bumped version
-version = '0.5.3'
+version = '0.5.4'
# Require
install_requires = [