Exemplo n.º 1
0
def blog():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('sundae')
    url1 = s.make_url_authed('picture/beijing.jpg')
    url2 = s.make_url_authed('picture/ziti.png')
    return render_template('blog.html', url0=url1, url1=url2)
Exemplo n.º 2
0
def html_form():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('eggtart')
    url = s.make_url_authed('picture/bj1.gif')
    whuurl = s.make_url_authed('picture/whu.jpg')
    return render_template('html_form.html', url=url, url1=whuurl)
Exemplo n.º 3
0
def who():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('sundae')
    url1 = s.make_url_authed('picture/who.png')
    url0 = s.make_url_authed('picture/bj1.gif')
    url2 = s.make_url_authed('picture/i.png')
    return render_template('who.html', url0=url0, url1=url1, url2=url2)
Exemplo n.º 4
0
def phone():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('eggtart')
    bkdurl = s.make_url_authed('picture/P50714-095115.jpg')
    whuurl = s.make_url_authed('picture/whu.jpg')
    pcurl = s.make_url_authed('picture/computer.png')
    blogurl = s.make_url_authed('picture/blog.png')
    return render_template('phone.html', url1=bkdurl, url2=whuurl, url3=pcurl, url4=blogurl)
Exemplo n.º 5
0
def hello():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('eggtart')
    pcurl = s.make_url_authed('picture/computer.png')
    phoneurl = s.make_url_authed('picture/phone.png')
    blogurl = s.make_url_authed('picture/blog.png')
    whuurl = s.make_url_authed('picture/whu.jpg')
    cycleurl = s.make_url_authed('picture/cycle.JPG')
    return render_template('home.html', url1=pcurl, url2=phoneurl, url3=blogurl, url4=whuurl, url5=cycleurl)
Exemplo n.º 6
0
def year():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('sundae')
    password = request.form['password']
    url0 = s.make_url_authed('picture/bj1.gif')
    url1 = s.make_url_authed('picture/boom.jpg')
    url2 = s.make_url_authed('picture/tree.jpg')
    url3 = s.make_url_authed('picture/snow.jpg')
    url4 = s.make_url_authed('picture/we.jpg')
    url5 = s.make_url_authed('picture/me.png')
    url7 = s.make_url_authed('picture/001.png')
    if password == u'王璐琰':
        c = SCSBucket('brokenmist')
        url10 = c.make_url_authed('picture/bj1.gif')
        url11 = c.make_url_authed('picture/w1.jpg')
        url12 = c.make_url_authed('picture/w2.jpg')
        url13 = c.make_url_authed('picture/w4.jpg')
        return render_template('wly.html', url10=url10, url11=url11, url12=url12, url13=url13, url14=url7)
    else:
        names = (****************************************************************************************)
        num = len(names)
        for i in range(0, num):
            if password == names[i][0]:
                na = names[i][1]
                words = name.example(na)
                nameurl = s.make_url_authed('picture/'+na+'.png')
                return render_template('newyear.html', url1=url1, url2=url2, url3=url3, url4=url4, url5=url5, nameurl=nameurl, words=words)
        return render_template('seeyou.html', url0=url0)
Exemplo n.º 7
0
def signin_form():
    global opener, cookie, handler
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('eggtart')
    user_Agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586'
    headers = {"User-Agent": user_Agent}
    url0 = 'http://210.42.121.132/servlet/GenImg'
    cookie = cookielib.CookieJar()
    handler = urllib2.HTTPCookieProcessor(cookie)
    opener = urllib2.build_opener(handler)
    req0 = urllib2.Request(url0, headers=headers)
    response = opener.open(req0)
    s.put('picture/123.jpg', response.read())
    url = s.make_url_authed('picture/123.jpg')
    return render_template('signin_test.html', pic=url)
    def test_make_url_authed(self):
        scs = SCSBucket(self.bucket_name)
        try:
            scs.put_bucket('private')
        except:
            self.fail('create bucket:%s is failed'%self.bucket_name)
        content = u'this is a file content text!!'
        canned_acl = 'private'                #快捷ACL
        scs.put(key=self.object_key, data=content, acl=canned_acl)
         
        url = scs.make_url_authed(key=self.object_key,expire=datetime.timedelta(minutes=5))
        #下载文件
#         import urllib2
#         response = urllib2.urlopen(url)
        from sinastorage.compat import urllib
        response = urllib.request.urlopen(url)
        self.assertEqual(len(content), int(response.info()['Content-Length']), 'The response header Content-Length is not match')
Exemplo n.º 9
0
def qing():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('eggtart')
    url = s.make_url_authed('picture/bj1.gif')
    url0 = s.make_url_authed('picture/c4.jpg')
    url1 = s.make_url_authed('picture/c5.jpg')
    url2 = s.make_url_authed('picture/c6.jpg')
    url3 = s.make_url_authed('picture/c8.jpg')
    url4 = s.make_url_authed('picture/c0.jpg')
    url5 = s.make_url_authed('picture/c1.jpg')
    url6 = s.make_url_authed('picture/c7.jpg')
    url7 = s.make_url_authed('picture/c2.jpg')
    url8 = s.make_url_authed('picture/c3.jpg')
    url9 = s.make_url_authed('picture/whu.jpg')
    return render_template('cycle.html', url=url, url0=url0, url1=url1, url2=url2, url3=url3, url4=url4, url5=url5, url6=url6, url7=url7, url8=url8, whuurl=url9,)
Exemplo n.º 10
0
def chuan():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('eggtart')
    url = s.make_url_authed('picture/bj1.gif')
    url0 = s.make_url_authed('picture/q3.JPG')
    url1 = s.make_url_authed('picture/q4.JPG')
    url2 = s.make_url_authed('picture/q7.jpg')
    url3 = s.make_url_authed('picture/q2.jpg')
    url4 = s.make_url_authed('picture/q1.jpg')
    url5 = s.make_url_authed('picture/q8.jpg')
    url6 = s.make_url_authed('picture/q5.JPG')
    url7 = s.make_url_authed('picture/q0.jpg')
    url8 = s.make_url_authed('picture/q6.jpg')
    url9 = s.make_url_authed('picture/whu.jpg')
    return render_template('cycle.html', url=url, url0=url0, url1=url1, url2=url2, url3=url3, url4=url4, url5=url5, url6=url6, url7=url7, url8=url8, whuurl=url9,)
Exemplo n.º 11
0
    def POST(self):
        try:
            webData = web.data()
            print "Handle Post webdata is ", webData
            recMsg = receive.parse_xml(webData)
            if isinstance(recMsg, receive.Msg):
                toUser = recMsg.FromUserName
                fromUser = recMsg.ToUserName
                if recMsg.MsgType == 'event':
                    event = recMsg.Event
                    if event == 'subscribe':
                        replyMsg = reply.TextMsg(
                            toUser, fromUser,
                            '欢迎订阅【在路上随风走】,回复“功能介绍”可查看功能简介噢,对了,在这还可以和机器人语音聊天呢,更多精彩就等你自己探索啦!'
                        )
                        return replyMsg.send()
                if recMsg.MsgType == 'text':
                    content = recMsg.Content
                    if content == '电台' or content == 'fm' or content == 'Fm' or content == 'FM':
                        replyMsg = reply.FmMsg(toUser, fromUser)
                        return replyMsg.send()
                    if content == '糗百' or content == '糗事百科' or content == '臭事百科' or content == '丑事百科':
                        word = joke.Joke()
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '段子' or content == '内涵段子' or content == '内涵段子手':
                        word = joke.Duanzi()
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '搞笑图片' or content == '内涵图片' or content == '内涵图':
                        word = joke.Pic()
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '成绩单' or content == '成绩' or content == '查成绩' or content == '成绩查询':
                        word = '把链接复制到浏览器中查询速度更快(⊙o⊙)哦'+'\n' + \
                            'http://sundae.applinzi.com/signin'
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '动机院公告' or content == '动机院' or content == '武大动机' or content == '动力与机械学院':
                        word = joke.WhuPmc()
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '机电学院' or content == '北理机电' or content == '机电学院公告':
                        word = joke.BitSmen()
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:4] == 'send' or content[0:4] == 'Send':
                        txt = content[5:-1] + content[-1]
                        word = qqzone.Send(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:5] == 'train' or content[0:5] == 'Train':
                        txt = content[6:-1] + content[-1]
                        word = train.train(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:5] == 'morse' or content[
                            0:5] == 'Morse' or content[0:5] == 'MORSE':
                        txt = content[6:-1] + content[-1]
                        word = morse.morse(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:2] == 'm0' or content[0:2] == 'M0':
                        txt = content[3:-1] + content[-1]
                        word = morse.morse(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:6] == 'umorse' or content[
                            0:6] == 'Umorse' or content[0:6] == 'UMORSE':
                        txt = content[7:-1] + content[-1]
                        word = morse.umorse(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:3] == 'um0' or content[
                            0:3] == 'Um0' or content[0:2] == 'UM0':
                        txt = content[4:-1] + content[-1]
                        word = morse.umorse(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:2] == 'm1' or content[0:2] == 'M1':
                        txt = content[3:-1] + content[-1]
                        word = morse.morse1(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:3] == 'um1' or content[0:3] == 'UM1':
                        txt = content[4:-1] + content[-1]
                        word = morse.umorse1(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:2] == 'ip' or content[0:2] == 'Ip' or content[
                            0:2] == 'IP':
                        txt = content[3:-1] + content[-1]
                        word = ip.target(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:2] == 'hp' or content[0:2] == 'Hp' or content[
                            0:2] == 'HP':
                        txt = content[3:-1] + content[-1]
                        word = free.freestyle(txt)
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '余额' or content == '校园卡余额':
                        word = '把链接复制到浏览器中查询速度更快(⊙o⊙)哦'+'\n' + \
                            'http://sundae.applinzi.com/signin'
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '关机':
                        word = smtp.smtp()
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '监控' or content == '远程监控':
                        word = smtp.control()
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == 'html' or content == '源代码':
                        word = '欢迎使用网页源代码查询功能' + '\n' + 'http://sundae.applinzi.com/html'
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '主页' or content == 'Sundae' or content == '网站' or content == 'sundae':
                        word = '欢迎访问 Sundae『在路上随风走』个人网站' + '\n' + 'http://sundae.applinzi.com/home'
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '博客':
                        word = '欢迎访问 Sundae『在路上随风走』个人博客' + '\n' + 'http://sundae.applinzi.com/blog'
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == '骑行日记':
                        word = '欢迎访问 Sundae『在路上随风走』个人博客——骑行日记' + '\n' + 'http://sundae.applinzi.com/diary'
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content[0:2] == 'QR' or content[0:2] == 'qr' or content[
                            0:2] == 'Qr':
                        txt = content[3:-1] + content[-1]
                        sinastorage.setDefaultAppInfo(
                            'w5il63SKTaSzZlCvuy8l',
                            'ae6523ffe7531606e34a6285fd3554f9203e2a2e')
                        s = SCSBucket('sundae')
                        url = s.make_url_authed('picture/whubj.jpg')
                        qrurl = 'http://qr.topscan.com/api.php?text=' + txt
                        replyMsg = reply.QrMsg(toUser, fromUser, url, qrurl)
                        return replyMsg.send()
                    if content == '功能介绍' or content == '功能' or content == '功能简介':
                        word = '''
功能简介:
1.聊天机器人,支持文字聊天和语音聊天。
2.电台,收听电台,关键字:电台。
3.成绩查询,查询所有成绩,关键字:成绩查询、成绩单等。
4.糗事百科,后台爬虫爬取糗百官网最新最热段子,关键字:糗百等。
5.内涵段子,后台爬虫爬取内涵段子官网最新段子,关键字:段子。
6.搞笑图片,后台爬虫爬取内涵段子官网内涵图,关键字:内涵图、搞笑图片等。
7.武汉大学动机院公告,爬取了官网抓了同步更新的公告,关键字:动机院等。
8.北京理工大学机电学院公告,爬取了官网同步更新的公告,关键字:机电学院等。
9.网站,我的个人网站,关键字:网站等。
10.博客,我的个人博客,关键字:博客等。
11.网页源代码,在手机上也可以查看指定网站的源代码,关键字:源代码等。
12.Python,介绍Python语言,毕竟我后台就是用Python写的,关键字:Python。
13.火车车次,输入“train 车次”直接查询列车时刻表,关键字:Train 车次。
14.二维码,输入“QR 文字”可将文字转变为二维码,关键字:Qr、QR等。
15.摩斯密码,可以进行摩斯密码加解密,关键字:Morse、Umorse、m1、um1等。
16.IP地址,输入“ip xx.xx.xx.xx”可以查询指定IP的地址,关键字:IP、ip等。
17.有freestyle吗,输入“hp 词语”可查询相关的押韵词语,关键字:hp、Hp等。
                        
所有关键字都支持模糊匹配,比如动机院公告、武大动机、动机院等都是同一个关键字。
                        
剩下的都是我的个人功能就不告诉大家了哈~~~
                        '''
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    if content == 'import this' or content == '后台' or content == 'Python' or content == 'python':
                        word = '''
The Zen of Python, by Tim Peters
                        
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
                        '''
                        replyMsg = reply.TextMsg(toUser, fromUser, word)
                        return replyMsg.send()
                    word = robot.Robot(content, toUser)
                    replyMsg = reply.TextMsg(toUser, fromUser, word)
                    return replyMsg.send()
                if recMsg.MsgType == 'image':
                    mediaId = recMsg.MediaId
                    replyMsg = reply.ImageMsg(toUser, fromUser, mediaId)
                    return replyMsg.send()
                if recMsg.MsgType == 'voice':
                    content = recMsg.Recognition
                    word = robot.Robot(content, toUser)
                    replyMsg = reply.TextMsg(toUser, fromUser, word)
                    return replyMsg.send()
                else:
                    return reply.Msg().send()
            else:
                print "Wait..."
                return 'success'
        except Exception, Argument:
            return Argument
Exemplo n.º 12
0
def happy():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('sundae')
    e = SCSBucket('eggtart')
    url1 = s.make_url_authed('picture/bj2.gif')
    url2 = s.make_url_authed('picture/bianpao.gif')
    url3 = s.make_url_authed('picture/dui0.gif')
    url4 = s.make_url_authed('picture/door.gif')
    url5 = s.make_url_authed('picture/deng.gif')
    url6 = s.make_url_authed('picture/ji.gif')
    url7 = s.make_url_authed('picture/ren.gif')
    url8 = s.make_url_authed('picture/tu.gif')
    url9 = s.make_url_authed('picture/yuan.gif')
    url10 = s.make_url_authed('picture/cai.gif')
    url11 = s.make_url_authed('picture/fa.gif')
    url12 = s.make_url_authed('picture/zong.gif')
    url13 = s.make_url_authed('picture/lazha.png')
    whuurl = e.make_url_authed('picture/whu.jpg')
    return render_template('happy.html', url1=url1, url2=url2, url3=url3, url4=url4, url5=url5, url6=url6,
                           url7=url7, url8=url8, url9=url9, url10=url10, url11=url11, url12=url12, url13=url13, whuurl=whuurl)
Exemplo n.º 13
0
def qzx():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('eggtart')
    url0 = s.make_url_authed('picture/bj1.gif')
    return render_template('diary_qzx.html', url0=url0)
Exemplo n.º 14
0
def czx():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('eggtart')
    url0 = s.make_url_authed('picture/bj1.gif')
    url1 = s.make_url_authed('picture/cz1.jpg')
    url11 = s.make_url_authed('picture/czx.JPG')
    url12 = s.make_url_authed('picture/cz0.jpg')
    url2 = s.make_url_authed('picture/cz22.jpg')
    url21 = s.make_url_authed('picture/cz21.jpg')
    url22 = s.make_url_authed('picture/cz23.jpg')
    url31 = s.make_url_authed('picture/c0.jpg')
    url32 = s.make_url_authed('picture/cz31.jpg')
    url33 = s.make_url_authed('picture/cz32.jpg')
    url34 = s.make_url_authed('picture/cz33.jpg')
    url35 = s.make_url_authed('picture/cz34.jpg')
    url36 = s.make_url_authed('picture/cz35.jpg')
    url41 = s.make_url_authed('picture/cz41.jpg')
    url42 = s.make_url_authed('picture/cz42.jpg')
    url43 = s.make_url_authed('picture/cz43.jpg')
    url44 = s.make_url_authed('picture/cz44.jpg')
    url45 = s.make_url_authed('picture/cz45.jpg')
    url46 = s.make_url_authed('picture/cz46.jpg')
    url51 = s.make_url_authed('picture/cz51.jpg')
    url52 = s.make_url_authed('picture/cz52.jpg')
    url53 = s.make_url_authed('picture/cz53.jpg')
    url54 = s.make_url_authed('picture/cz54.jpg')
    url55 = s.make_url_authed('picture/cz55.jpg')
    url56 = s.make_url_authed('picture/cz56.jpg')
    url61 = s.make_url_authed('picture/cz61.jpg')
    url62 = s.make_url_authed('picture/cz62.jpg')
    url63 = s.make_url_authed('picture/cz63.jpg')
    return render_template('diary_czx.html', url0=url0, url1=url1, url11=url11, url12=url12, url2=url2, url21=url21, url22=url22,
                           url31=url31, url32=url32, url33=url33, url34=url34, url35=url35, url36=url36, url41=url41, url42=url42,
                           url43=url43, url44=url44, url45=url45, url46=url46, url51=url51, url52=url52, url53=url53, url54=url54,
                           url55=url55, url56=url56, url61=url61, url62=url62, url63=url63)
Exemplo n.º 15
0
def diary():
    sinastorage.setDefaultAppInfo(
        '***********************', '*************************************')
    s = SCSBucket('sundae')
    url0 = s.make_url_authed('picture/beijing.jpg')
    return render_template('diary.html', url0=url0)
Exemplo n.º 16
0
def make_url_authed():
    s = SCSBucket('test11')
    return s.make_url_authed('testpdf.pdf')