示例#1
0
def PlatformCheck(event):
    Fields = event["fields"]
    Channel = Fields['Channel']
    for platform in Channel:
        print (platform)
        if platform.lower() == "twitter":
            print ("run TWT")
            TWT.main(event)
        elif platform.lower() == "facebook":
            print ("run FB")
            FB.main(event)
        elif platform.lower() == "instagram":
            print ("run IG")
            IG.main(event)
        else:
            ############WRITE CONFIG FILES ##################
            ###     Writes the event info to errors.cfg   ###
            #################################################
            print("ERROR : invalid platform")
            conf = ConfigParser.RawConfigParser()
            start = event['start'].get('dateTime', event['start'].get('date'))
            conf.add_section('Wrong Platform')
            info =  str(start)+"|"+str(event['summary'])+"|"+str(event['description'])
            conf.set('Wrong Platform', info)
            # Writing our configuration file to 'errors.cfg'
            with open('Lib/errors.cfg', 'wb') as configfile:
                conf.write(configfile)
示例#2
0
def login():
    session["user"] = FB.getID( session["token"] )
    session["name"] = FB.getName( session["token"] )
    if database_actions.isRegistered( session["user"] ):
        print "logging in"
        database_actions.login_user( session["user"] )
    else:
        print "registering "
        database_actions.register_user( session["name"], session["user"] )
    return redirect( "/" )
示例#3
0
def login():
    session["user"] = FB.getID(session["token"])
    session["name"] = FB.getName(session["token"])
    if database_actions.isRegistered(session["user"]):
        print "logging in"
        database_actions.login_user(session["user"])
    else:
        print "registering "
        database_actions.register_user(session["name"], session["user"])
    return redirect("/")
示例#4
0
def settings(event_id):
    event = database_actions.get_event(session["user"], event_id)
    session["event_in_progress"] = int(event_id.encode("utf8"))
    return render_template("settings.html",
                           index=event_id,
                           facebook_events=FB.getHostedEvents(
                               session["token"]),
                           event=event)
示例#5
0
def set():
    #try:
    if 'user' not in session:
        return redirect("/")
    elif request.method == "POST":

        session["event_in_progress"] = len(
            database_actions.get_events(session["user"]))
        print session["event_in_progress"]
        ID = request.form["fb_id"]
        token = session["token"]
        description = FB.getDescription(token, ID)
        date = FB.getStartTime(token, ID)
        location = FB.getLocation(token, ID)
        attending = FB.getAttending(token, ID)
        maybe = FB.getMaybe(token, ID)
        declined = FB.getDeclined(token, ID)
        not_responded = FB.getUnknown(token, ID)
        print database_actions.add_event(session["user"], request.form["name"],
                                         request.form["theme"], ID,
                                         description, date, location,
                                         attending, declined, maybe,
                                         not_responded)

        return render_template('set.html',
                               events=database_actions.get_events(
                                   session["user"]))
    return redirect("/new")
    #except:
    session.pop("user")
    return redirect("/")
示例#6
0
def set():
        #try:
                if 'user' not in session:
                        return redirect( "/" )
                elif request.method == "POST":


                    session["event_in_progress"] = len( database_actions.get_events( session["user"] ) )
                    print session["event_in_progress"]
                    ID = request.form["fb_id"]
                    token = session["token"]
                    description = FB.getDescription( token, ID )
                    date = FB.getStartTime( token, ID )
                    location = FB.getLocation( token, ID )
                    attending = FB.getAttending( token, ID )
                    maybe =  FB.getMaybe( token, ID )
                    declined = FB.getDeclined( token, ID )
                    not_responded = FB.getUnknown( token, ID )
                    print database_actions.add_event( session["user"], request.form["name"], request.form["theme"], ID, description, date, location, attending, declined, maybe, not_responded )


                    return render_template( 'set.html', events=database_actions.get_events( session["user"] ) )
                return redirect( "/new" )
        #except:
                session.pop( "user" )
                return redirect( "/" )
示例#7
0
def new_event():

        try:
                if 'user' not in session:
                        return redirect('/')
                return render_template( 'create.html', facebook_events=FB.getHostedEvents( session["token"] ), events=database_actions.get_events( session["user"] ) )
        except:
                session.pop( "user" )
                return redirect( "/" )
示例#8
0
def new_event():

    try:
        if 'user' not in session:
            return redirect('/')
        return render_template(
            'create.html',
            facebook_events=FB.getHostedEvents(session["token"]),
            events=database_actions.get_events(session["user"]))
    except:
        session.pop("user")
        return redirect("/")
示例#9
0
def updatefb( event_index ):
    if 'user' not in session:
        return redirect( "/" )
    ID = database_actions.get_fbid(session["user"],event_index)
    token = session["token"]
    description = FB.getDescription( token, ID )
    date = FB.getStartTime( token, ID )
    location = FB.getLocation( token, ID )
    attending = FB.getAttending( token, ID )
    maybe =  FB.getMaybe( token, ID )
    declined = FB.getDeclined( token, ID )
    not_responded = FB.getUnknown( token, ID )
    print database_actions.update_event( session["user"], int( event_index.encode("utf8") ), description, date, location, attending, declined, maybe, not_responded)
    return redirect("/event/"+event_index)
示例#10
0
def updatefb(event_index):
    if 'user' not in session:
        return redirect("/")
    ID = database_actions.get_fbid(session["user"], event_index)
    token = session["token"]
    description = FB.getDescription(token, ID)
    date = FB.getStartTime(token, ID)
    location = FB.getLocation(token, ID)
    attending = FB.getAttending(token, ID)
    maybe = FB.getMaybe(token, ID)
    declined = FB.getDeclined(token, ID)
    not_responded = FB.getUnknown(token, ID)
    print database_actions.update_event(session["user"],
                                        int(event_index.encode("utf8")),
                                        description, date, location, attending,
                                        declined, maybe, not_responded)
    return redirect("/event/" + event_index)
示例#11
0
文件: main.py 项目: iitzex/tpeclsd
    pat = "INT OF TWY (.*) AND TWY (.*) CLSD"
    all = re.search(pat, context, re.DOTALL)
    part1 = all.group(1)
    part2 = all.group(2)

    pat = "(.*), TWY (.*)"
    section = re.search(pat, all.group(1), re.DOTALL)
    if section != None:
        # print section.group(1)
        # print section.group(2)
        part1 = section.group(1)

    cross = part1 + "_" + part2
    print "^ " + cross

    intersectionCLSD(cross, linestyle=linestyle)

if __name__ == '__main__':
    if checkNOTAM() or checkFirstPost():
        print checkNOTAM()
        print checkFirstPost()
        today = getday()
        traverseNOTAM()
        savePNG(today)

        if len(sys.argv) == 1:
            FB.post_graph(today, "")
    else:
        print "No NOTAM"
示例#12
0
# -*-coding: utf-8 -*-
import feedparser
import html2text
import FB

d = feedparser.parse("http://www.tmd.go.th/xml/region_daily_forecast.php?RegionID=7")
# print d['feed']['title']
# print d['feed']['link']
title = d["feed"]["title"]
link = d["feed"]["link"]
# print "------------------"
txt = d.entries[0]["summary_detail"]["value"]
# print txt
# print "------------------"

plain_txt = html2text.html2text(txt)
i = plain_txt.find("![]")
j = plain_txt.find(")", i)
img_link = plain_txt[i + 4 : j]
s = plain_txt[i : j + 1]
# print "image link:'",img_link,"'"

plain_txt = title + "\n" + plain_txt.replace(s, "") + "\n" + link
print plain_txt.encode("utf-8")
FB.post_wall(plain_txt.encode("utf-8"))
示例#13
0
def wordRateFB(obj_id):
    feed = FB.getFeed(obj_id)

    # у каждой группы достаем посты
    col = [post['message'] for post in feed]
    return wordRate(col)
示例#14
0
文件: postXD.py 项目: kcommerce/AWS
caption=""

def isNewDate(date1):
	file = open(datafile,"r+")
	data = file.read()
	print "Old date:",data
	if (date1 == data):
		result = False
	else:
		file.seek(0,0)
		file.write(str(date1))
		result = True
	file.close()
	return result


d=feedparser.parse('http://feeds.feedburner.com/Setorth-Xd')
updated =  d['feed']['updated']
link =  d['feed']['links'][0]['href']
#print d['feed']
txt = ""
if (isNewDate(updated)):
	print "New update:", updated
	for i in d.entries:
		txt = txt + i['title'] +"\n"
	txt = txt.rstrip()
	textToImage.txt2imageNLXD(filename,txt,caption)
	FB.post_photo(filename,link,'10153759221199127')
else:
	print "No update since:",updated
示例#15
0
def settings( event_id ):
    event = database_actions.get_event( session["user"], event_id )
    session["event_in_progress"] = int(event_id.encode("utf8"))
    return render_template( "settings.html", index=event_id, facebook_events=FB.getHostedEvents( session["token"] ), event=event )
示例#16
0
	print "Old date:",data
	if (date1 == data):
		result = False
	else:
		file.seek(0,0)
		file.write(str(date1))
		result = True
	file.close()
	return result


d=feedparser.parse('http://feeds.feedburner.com/Setorth-form45')
updated =  d['feed']['updated']
link =  d['feed']['links'][0]['href']
#print d['feed']
#print "Link:",link
txt = ""
if (isNewDate(updated)):
	print "New update:", updated
	for i in d.entries:
		txt = txt + i['title'] +"\n"
	txt = txt.rstrip()
	txt = link+"\n"+ txt
	#print "Txt:",txt
	if (txt.find("http") <=5):
		print "No update"
	else:
		FB.post_wall(txt.encode("utf-8"))
else:
	print "No update since:",updated