print('\n')
if input('Update coding journal on website? ').lower()[0] == 'y':
    subprocess.call(["pandoc -f markdown -s -t html5 -o '/~patrick/projects/UlyssesRedux/coding.html' '/UlyssesRedux/coding thoughts.md'"], shell=True)
    subprocess.call(['patch /~patrick/projects/UlyssesRedux/coding.html /UlyssesRedux/coding\ thoughts.patch'], shell=True)
    subprocess.call(['rm /~patrick/projects/UlyssesRedux/coding.html.bak'], shell=True)
    subprocess.call(['tidy -m -i -w 0 -utf8 --doctype html5 --fix-uri true --new-blocklevel-tags footer --quote-nbsp true --preserve-entities yes /~patrick/projects/UlyssesRedux/coding.html'], shell=True)

if input('Update meta-TOC on local copy of website? ').lower()[0] == 'y':
    with open(meta_TOC_path) as TOC_file:
        TOC_text = TOC_file.read()
    TOC_split = TOC_text.split('</ol>')     # Works as long as there's only one ordered list in the document
    TOC_text = TOC_split[0] + '<li class="vevent"><a class="url location" rel="me muse" href="%03d.html"><cite class="book-title">%s</cite></a> (<span class="dtstart">%s</span>): <span class="summary description">%s</span></li>' % (current_episode_number, current_run_data['current-run-name'], time.strftime("%Y-%m-%d"), current_run_data['summary']) + '\n  </ol>\n</section>\n</div>\n</body>\n</html>'
    with open(meta_TOC_path, 'w') as TOC_file:
        TOC_file.write(TOC_text)

if input('Sync web page to main site? ').lower()[0] == 'y':
    # This script lives on my hard drive at ~/.scripts/sync-website.sh
    subprocess.check_call(['sync-website.sh'], shell=True)

if input("Want to tweet about the new edition that's out? ").lower()[0] == 'y':
    the_tweet = 'Ulysses Redux # %03d (%s) is out: %s%03d' % (current_episode_number, current_run_data['current-run-name'], remote_webpage_contents, current_episode_number)
    if input("Want to use the suggested tweet '%s'? " % the_tweet).lower()[0] != 'y':
        the_tweet = "X" * 200
        while len(the_tweet) > 117:     # 117 seems to be the maximum length of a tweet not counting a single URL that it contains.
            the_tweet = input("OK, Shakespeare, write a tweet of 117 characters or less yourself: ")
    social_media.post_tweet(social_media_auth.personalTwitter_client, the_tweet)

print('\n\n')
if input("We're done here. Want to set up the next run? ").lower()[0] == 'y':
    subprocess.check_call(['/UlyssesRedux/code/utility_scripts/setup-run.py'], shell=True)
        elif opt in ('-a', '--archive'):
            patrick_logger.log_it('INFO: ' + opt + ' invoked; tweet archive set to ' + args, 2)
            tweet_archive_path = args
        elif opt == '--sort-archive':
            patrick_logger.log_it('INFO: --sort-archive specified; sorting and exiting')
            sort_archive()
            sys.exit()
else:
    patrick_logger.log_it('DEBUGGING: No command-line parameters', 2)

patrick_logger.log_it('DEBUGGING: patrick_logger.verbosity_level after parsing command line is ' +str(patrick_logger.verbosity_level))

# All right, start processing
got_it = False

while not got_it:
    the_tweet = get_a_tweet()
    if the_tweet in open(tweet_archive_path).read():    # Incidentally, this is a bad idea if the tweets log ever gets very big
        patrick_logger.log_it("That was already tweeted! Trying again ...\n\n\n")
    else:
        got_it = True
        patrick_logger.log_it("Aaaaaand that one's new. Tweeting it ...\n\n")

# Now, post the tweet.
status = social_media.post_tweet(IrishLitTweets_client, the_tweet)
# If everything worked, add the tweet to the tweet archive.
open(tweet_archive_path, 'a').write(the_tweet + "\n")
patrick_logger.log_it(pprint.pformat(vars(status)), 2)

# We're done.
Ejemplo n.º 3
0
It requires that the appropriate authentication constants are already set up
in social_media_auth.py.

This script is copyright 2017-20 by Patrick Mooney. It is licensed under the GNU
GPL, either version 3 or (at your option) any later version. See the file
LICENSE.md for details.
"""

import sys

import social_media, social_media_auth  # https://github.com/patrick-brian-mooney/personal-library

if len(sys.argv) <= 1:
    print('\n\n' + __doc__ % sys.argv[0])
    sys.exit(2)

if sys.argv[1] in ['-h', '--help']:
    print('\n\n' + __doc__ % sys.argv[0])
    sys.exit(0)

if __name__ == "__main__":
    the_tweet = ' '.join(sys.argv[1:])
    if len(the_tweet) > 280:
        print(
            "ERROR: Your tweet is %d characters long, which is more than 280."
            % len(the_tweet))
        sys.exit(1)
    social_media.post_tweet(
        the_tweet, client_credentials=social_media_auth.personalTwitter_client)
Ejemplo n.º 4
0
            current_episode_number, current_run_data['current-run-name'],
            time.strftime("%Y-%m-%d"), current_run_data['summary']
        ) + '\n  </ol>\n</section>\n</div>\n</body>\n</html>'
    with open(meta_TOC_path, 'w') as TOC_file:
        TOC_file.write(TOC_text)

if input('Sync web page to main site? ').lower()[0] == 'y':
    # This script lives on my hard drive at ~/.scripts/sync-website.sh
    subprocess.check_call(['sync-to-nfs.sh'], shell=True)

if input("Want to tweet about the new edition that's out? ").lower()[0] == 'y':
    the_tweet = 'Ulysses Redux # %03d (%s) is out: %s%03d' % (
        current_episode_number, current_run_data['current-run-name'],
        remote_webpage_contents, current_episode_number)
    if input("Want to use the suggested tweet '%s'? " %
             the_tweet).lower()[0] != 'y':
        the_tweet = "X" * 200
        while len(
                the_tweet
        ) > 117:  # 117 seems to be the maximum length of a tweet not counting a single URL that it contains.
            the_tweet = input(
                "OK, Shakespeare, write a tweet of 117 characters or less yourself: "
            )
    social_media.post_tweet(social_media_auth.personalTwitter_client,
                            the_tweet)

print('\n\n')
if input("We're done here. Want to set up the next run? ").lower()[0] == 'y':
    subprocess.check_call(
        ['/UlyssesRedux/scripts/utility_scripts/setup-run.py'], shell=True)