\r
rainbowstream -iot # Or rainbowstream --image-on-term\r
\r
-You also can change the config key ``IMAGE_ON_TERM`` to ``True`` inside the app \r
+You also can change the config key ``IMAGE_ON_TERM`` to ``True`` inside the app\r
to enable above feature (see `config management`_ section).\r
\r
In the first time you will be asked for authorization of Rainbow Stream\r
\r
- ``h`` will show the help.\r
\r
+- ``p`` will pause the stream.\r
+\r
+- ``r`` will unpause the stream.\r
+\r
- ``c`` will clear the screen.\r
\r
- ``q`` will quit.\r
\r
+ ``CLOCK_FORMAT``: time format, see `Python's strftime format`_.\r
+ ``DISPLAY``: decide how tweet will be printed.\r
- \r
+\r
+ ``#name``: Twitter's name\r
+ ``#nick``: Twitter's screen name\r
+ ``#clock``: Datetime\r
return res
- def semaphore_store(self, flag):
+ def semaphore_store(self, flag, pause):
"""
Store semaphore flag
"""
Session = sessionmaker(bind=self.engine)
session = Session()
- th = Semaphore(flag)
+ th = Semaphore(flag, pause)
session.add(th)
session.commit()
- def semaphore_update(self, flag):
+ def semaphore_update_flag(self, flag):
"""
Update semaphore flag
"""
session.commit()
- def semaphore_query(self):
+ def semaphore_update_pause(self, pause):
"""
- Query semaphore
+ Update semaphore pause
+ """
+ Session = sessionmaker(bind=self.engine)
+ session = Session()
+ res = session.query(Semaphore).all()
+ for r in res:
+ r.pause = pause
+ session.commit()
+
+
+ def semaphore_query_flag(self):
+ """
+ Query semaphore flag
"""
Session = sessionmaker(bind=self.engine)
session = Session()
res = session.query(Semaphore).all()
return res[0].flag
+
+
+ def semaphore_query_pause(self):
+ """
+ Query semaphore pause
+ """
+ Session = sessionmaker(bind=self.engine)
+ session = Session()
+ res = session.query(Semaphore).all()
+ return res[0].pause
'config',
'theme',
'h',
+ 'p',
+ 'r',
'c',
'q'
]
g['themes'] = themes
db.theme_store(c['THEME'])
# Semaphore init
- db.semaphore_store(False)
+ db.semaphore_store(False, False)
# Image on term
c['IMAGE_ON_TERM'] = args.image_on_term
slug=slug,
owner_screen_name=owner,
screen_name=user_name)
- printNicely(light_green('Added.'))
+ printNicely(green('Added.'))
except:
printNicely(light_magenta('I\'m sorry we can not add him/her.'))
slug=slug,
owner_screen_name=owner,
screen_name=user_name)
- printNicely(light_green('Gone.'))
+ printNicely(green('Gone.'))
except:
printNicely(light_magenta('I\'m sorry we can not remove him/her.'))
t.lists.subscribers.create(
slug=slug,
owner_screen_name=owner)
- printNicely(light_green('Done.'))
+ printNicely(green('Done.'))
except:
printNicely(
light_magenta('I\'m sorry you can not subscribe to this list.'))
t.lists.subscribers.destroy(
slug=slug,
owner_screen_name=owner)
- printNicely(light_green('Done.'))
+ printNicely(green('Done.'))
except:
printNicely(
light_magenta('I\'m sorry you can not unsubscribe to this list.'))
name=name,
mode=mode,
description=description)
- printNicely(light_green(name + ' list is created.'))
+ printNicely(green(name + ' list is created.'))
except:
printNicely(red('Oops something is wrong with Twitter :('))
owner_screen_name=g['original_name'],
mode=mode,
description=description)
- printNicely(light_green(slug + ' list is updated.'))
+ printNicely(green(slug + ' list is updated.'))
except:
printNicely(red('Oops something is wrong with Twitter :('))
t.lists.destroy(
slug='-'.join(slug.split()),
owner_screen_name=g['original_name'])
- printNicely(light_green(slug + ' list is deleted.'))
+ printNicely(green(slug + ' list is deleted.'))
except:
printNicely(red('Oops something is wrong with Twitter :('))
if not g['stuff']:
for k in all_config:
line = ' ' * 2 + \
- light_green(k) + ': ' + light_yellow(str(all_config[k]))
+ green(k) + ': ' + light_yellow(str(all_config[k]))
printNicely(line)
guide = 'Detailed explanation can be found at ' + \
color_func(c['TWEET']['link'])(
if g['stuff'] in all_config:
k = g['stuff']
line = ' ' * 2 + \
- light_green(k) + ': ' + light_yellow(str(all_config[k]))
+ green(k) + ': ' + light_yellow(str(all_config[k]))
printNicely(line)
else:
printNicely(red('No such config key.'))
key = g['stuff'].split()[0]
try:
value = get_default_config(key)
- line = ' ' * 2 + light_green(key) + ': ' + light_magenta(value)
+ line = ' ' * 2 + green(key) + ': ' + light_magenta(value)
printNicely(line)
except:
printNicely(
key = g['stuff'].split()[0]
try:
delete_config(key)
- printNicely(light_green('Config key is dropped.'))
+ printNicely(green('Config key is dropped.'))
except:
printNicely(red('No such config key.'))
# Set specific config
g['decorated_name'] = lambda x: color_func(
c['DECORATED_NAME'])(
'[' + x + ']: ')
- printNicely(light_green('Updated successfully.'))
+ printNicely(green('Updated successfully.'))
except:
printNicely(light_magenta('Not valid value.'))
return
usage += '\n'
usage += s + grey(u'\u266A' + ' Screening \n')
usage += s * 2 + light_green('h') + ' will show this help again.\n'
+ usage += s * 2 + light_green('p') + ' will pause the stream.\n'
+ usage += s * 2 + light_green('r') + ' will unpause the stream.\n'
usage += s * 2 + light_green('c') + ' will clear the screen.\n'
usage += s * 2 + light_green('q') + ' will quit.\n'
# End
printNicely(usage)
+def pause():
+ """
+ Pause stream display
+ """
+ db.semaphore_update_pause(True)
+ printNicely(green('Stream is paused'))
+
+
+def replay():
+ """
+ Replay stream
+ """
+ db.semaphore_update_pause(False)
+ printNicely(green('Stream is running back now'))
+
+
def clear():
"""
Clear screen
config,
theme,
help,
+ pause,
+ replay,
clear,
quit
]
'list',
'stream'
], # help
+ [], # pause
+ [], # reconnect
[], # clear
[], # quit
]
g['cmd'] = cmd
try:
# Lock the semaphore
- db.semaphore_update(True)
+ db.semaphore_update_flag(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(False)
+ db.semaphore_update_flag(False)
except Exception:
printNicely(red('OMG something is wrong with Twitter right now.'))