User:Inge Hoonte/captain tweet: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 3: Line 3:
'''ADD ME ON http://twitter.com/#!/tweet_captain'''
'''ADD ME ON http://twitter.com/#!/tweet_captain'''


After much circling around new ideas, while focusing on finishing Captain Tweet, I decided to let a few new kernels and smaller works wait for some other time. Aymeric has helped me steadily progress with the code. And I'm starting to understand dictionaries and strings better.  
Aymeric has helped me steadily progress with the code for Captain Tweet. And I'm starting to understand dictionaries and strings better.  


Some important things to note: <br/>
Some important things to note: <br/>
Line 12: Line 12:




== Source Code ==
== Inspiration & Process ==
'''CAPTAIN COOK'S TRAVEL LOG''' <br/>
'''CAPTAIN COOK'S TRAVEL LOG''' <br/>
[[File:capt_cook.jpg]]
[[File:capt_cook.jpg]]
Line 61: Line 61:


'''CODE''' <br/>
'''CODE''' <br/>
  #!/usr/bin/python
  #!/usr/bin/python
  #from datetime import datetime
  from datetime import datetime
import time, sys
import tweepy
   
   
  log = {}
  log = {}
Line 72: Line 74:
  daylog = day.split("\n")
  daylog = day.split("\n")
  day = daylog.pop(0)
  day = daylog.pop(0)
 
  entries = {}
  entries = {}
 
 
  for entry in daylog:
  for entry in daylog:
  event = entry.split(" ")
event = entry.split(" ")
  daytime = event.pop(0)
daytime = event.pop(0)
  entries[daytime] = " ".join(event)
if daytime in entries.keys():
entries[daytime] += "\n" + " ".join(event)
else:
entries[daytime] = " ".join(event)
     
     
  log[day] = entries
  log[day] = entries
 
#log into twitter
auth = tweepy.auth.OAuthHandler('COPY KEY HERE', 'COPY KEY HERE')
api = tweepy.API(auth)
 
#if not api.verify_credentials():
#print "Failed to log-in on Twitter API."
#sys.exit(1)
#print "Tweepy api.me() says: " + str(api.me())
previous_time = " "
#continuous match searching for date and time to push message
while True:
current_day = datetime.now().strftime("%m/%d")
current_time = datetime.now().strftime("%H:%M:")
if current_time == previous_time:
time.sleep(5)
continue
previous_time = current_time
print "there is no entry for " + current_day + current_time
if current_day not in log.keys():
continue
if current_time not in log[current_day].keys():
continue
 
 
#datetime.now()
#api.update_status(log[current_day][current_time])
print log[current_day][current_time]
   
   
   
   
print log['07/10']['06:00:']


'''Anomalies''' <br/>
'''Anomalies''' <br/>

Revision as of 12:29, 18 June 2011

Aye aye.png

ADD ME ON http://twitter.com/#!/tweet_captain

Aymeric has helped me steadily progress with the code for Captain Tweet. And I'm starting to understand dictionaries and strings better.

Some important things to note:

  • I changed the original dates to fit the format of the final show. Ideally I'd have this start on December 16, which is the first entry of the original log. But for the sake of the show now, I've changed it to June/July. So... in case you're wondering, that's why it's snowing in July. But I guess this could be the case, had the ship been sailing via the Arctic or Greenland.
  • The log used is a combination of Captain Turner's log, and the Muster's Roll, both have been transcribed by Sue Mackay, of Cardiff.
  • The Weymouth, the ship that's tweeted from, was used to transport 11 parties of 1820 settlers from Portsmouth, England, to Algoa Bay (Port Elizabeth), South-East Africa.
  • A big undertone of this project is of course migration, sailing the seas, colonialism, which isn't further explored. I needed to focus on advancing in my programming skills.


Inspiration & Process

CAPTAIN COOK'S TRAVEL LOG
Capt cook.jpg


ORIGINAL LOG BY CAPTAIN TURNER, 1819/1820
Weymouth.gif

Thurs 16 December 1819 – Portsmouth Harbour
Am: Light breezes and clear
8: Do weather. Employed hoisting in provisions and other necessary duties.
The settlers came on board at noon. Do weather. Employed stowing the hold.
Mustered for Checques, discharged several of the crew. Employed stowing the holds.
Midnight: Strong winds

Fri 17 December
Am: Strong breezes with rain
8: Do weather. Employed cleaning decks and stowing chain cables.
Do weather. Employed as before.
Midnight: Do weather

Sat 18 December
Am: Strong breezes and rain. Employed clearing lighter of provisions.
Pm: More moderate employed cleaning decks.
Midnight: Fine weather

Captain Tweet, 2011

Aye aye.png

06/16
01:00: Light breezes and clear
08:00: Ditto weather. Employed hoisting in provisions and other necessary duties.
15:00: The settlers came on board at noon. Ditto weather. Employed stowing the hold.
17:00: Mustered for Checques, discharged several of the crew. Employed stowing the holds.
23:59: Strong winds

06/17
01:00: Strong breezes with rain
08:00: Ditto weather. Employed cleaning decks and stowing chain cables.
15:00: Ditto weather. Employed as before.
23:59: Ditto weather

06/18
01:00: Strong breezes and rain. Employed clearing lighter of provisions.
15:00: More moderate employed cleaning decks.
23:59: Fine weather


CODE

#!/usr/bin/python
from datetime import datetime
import time, sys 

import tweepy

log = {}
journal = open("log.txt","r")
days = journal.read().split("\n\n")

for day in days:
	daylog = day.split("\n")
	day = daylog.pop(0)

	entries = {}
	
	for entry in daylog:
		event = entry.split(" ")
		daytime = event.pop(0)
		if daytime in entries.keys():
			entries[daytime] += "\n" + " ".join(event)
		else:
			entries[daytime] = " ".join(event)
	  
	log[day] = entries
 
#log into twitter
auth = tweepy.auth.OAuthHandler('COPY KEY HERE', 'COPY KEY HERE')
api = tweepy.API(auth)
 
#if not api.verify_credentials():
	#print "Failed to log-in on Twitter API."
	#sys.exit(1)
	
#print "Tweepy api.me() says: " + str(api.me())

previous_time = " "
#continuous match searching for date and time to push message
while True: 
	current_day = datetime.now().strftime("%m/%d")
	current_time = datetime.now().strftime("%H:%M:")
	if current_time == previous_time: 
		time.sleep(5)
		continue
	previous_time = current_time	
		
	print "there is no entry for " + current_day + current_time

	if current_day not in log.keys():
		continue
	if current_time not in log[current_day].keys():
		continue
	
	#api.update_status(log[current_day][current_time])
	print log[current_day][current_time]


Anomalies
Born on Board, not mentioned in the Cpt Log, but present in the Master's Roll:

Jan 13 ___ Pedlar
Jan 28 ___ Green
Feb 07 ___ Reed
Feb 20 ___ Biggar
Feb 29 ___ Epsey
Mar 08 ___ Godfrey
Mar 10 ___ Usher
Mar 22 ___ Hobbs DD 13 Apr
Apr 07 ___ Sweetman
Apr 26 ___ Bowker
Apr 29 ___ Sanders DD 7 May
May 18 ___ Cronk


References
http://www.theshipslist.com/ships/passengerlists/weymouth.htm >> this is the source log by Captain Turner

http://www.galapagos.to/TEXTS/BEAGLELOG.HTM

http://www.wielingen1991.org/en/mission_/log_book.htm >> ship employed in war

http://www.dailymail.co.uk/sciencetech/article-1218474/How-Captain-Cooks-ship-logs-helping-scientists-chart-global-climate-change.html


To Do:

  • update time in log to standardized 06:00 etc hours that Python can read
  • create new twitter account for the captain
  • make friends for the captain
  • put code and log on the server, run it from there
  • add to code: #check for date continuously and time, when there's a match, push message from log to captain's tweet feed


OLD CODE

#!/usr/bin/python

import twitter
import time
api = twitter.Api(username='...', password='...')

print('Starting...')

while 1 == 1:
       api.PostUpdate(getoutput('uptime'))
       print(getoutput('uptime'))
       time.sleep(3600)