Exemple #1
0
def main():
    wapi, user, citystr, newslink = h.kernfig()
    h.welcome(user)

    while True:
        wapi, user, citystr, newslink = h.kernfig()
        print(h.ask())
        uin = str.lower(input(">"))
        if "fetch" in uin:
            fetch.main(uin)

        elif "visit" in uin:
            for itemToVisit in h.giveComputerIndex(uin):
                newsfeed = h.grab(newslink)
                webbrowser.open(newsfeed.entries[itemToVisit - 1].link)

        elif "set" in uin:
            if "name" in uin:
                name = input("What would you like me to call you? ")
                h.cfgwriter("settings.cfg", 0, name)
            if "city" in uin:
                city = input("""
Changing weather location? Where to?
Must be in Wunderground form. """)
                h.cfgwriter("settings.cfg", 1, city)

        elif "name" and "pronounce" in uin:
            print(h.pipya() +
                  "My name is pronounced Pip-pah. The y is silent :).")

        elif "name" and ("how" or "where") and "get" in uin:
            print(h.pipya() + """\
My name started as pypa, for "python personal assistant". It morphed to pipya
for pronounceability. Thanks for asking!""")

        elif "what" and "can" and "do" in uin:
            h.capabilities()

        elif "who" and "are" and ("you" or "pipya") in uin:
            print(h.pipya() + """
I am Pipya, a personal assistant written in python3. My creator is brupoon.
He intended for me to be a jack-of-all-trades personal assistant operated by
a cli. I am a sexless, genderless entity, though my name is similar to the
human feminine "Pippa".
                """)

        elif uin in ["quit", "goodbye", "exit"]:
            print("Goodbye, {0}! 'Till next time.".format(user))
            sys.exit()

        elif uin in ["jellyfish"]:
            h.jellyfish()

        else:
            print("Pipya: Sorry, {0}, I didn't quite catch that.".format(user))
Exemple #2
0
def main():
    wapi, user, citystr,newslink = h.kernfig()
    h.welcome(user)

    while True:
        wapi, user, citystr,newslink = h.kernfig()
        print(h.ask())
        uin = str.lower(input(">"))
        if "fetch" in uin:
            fetch.main(uin)
            
        elif "visit" in uin:
            for itemToVisit in h.giveComputerIndex(uin):
                newsfeed = h.grab(newslink)
                webbrowser.open(newsfeed.entries[itemToVisit-1].link)

        elif "set" in uin:
            if "name" in uin:
                name = input("What would you like me to call you? ")
                h.cfgwriter("settings.cfg",0,name)
            if "city" in uin:
                city = input("""
Changing weather location? Where to?
Must be in Wunderground form. """)
                h.cfgwriter("settings.cfg",1,city)

        elif "name" and "pronounce" in uin:
            print(h.pipya()+"My name is pronounced Pip-pah. The y is silent :).")

        elif "name" and ("how" or "where") and "get" in uin:
            print(h.pipya()+"""\
My name started as pypa, for "python personal assistant". It morphed to pipya
for pronounceability. Thanks for asking!""")

        elif "what" and "can" and "do" in uin:
            h.capabilities()

        elif "who" and "are" and ("you" or "pipya") in uin:
            print(h.pipya()+"""
I am Pipya, a personal assistant written in python3. My creator is brupoon.
He intended for me to be a jack-of-all-trades personal assistant operated by
a cli. I am a sexless, genderless entity, though my name is similar to the
human feminine "Pippa".
                """)

        elif uin in ["quit", "goodbye", "exit"]:
            print("Goodbye, {0}! 'Till next time.".format(user))
            sys.exit()

        elif uin in ["jellyfish"]:
            h.jellyfish()

        else:
            print("Pipya: Sorry, {0}, I didn't quite catch that.".format(user))
Exemple #3
0
    def field_set(self, text):
        self.field.setText(text)
        if text == '--Select an option--':
            self.progress.hide()

        elif text == 'Motion Sensor':
            self.progress.show()
            self.loading()
            self.field2.show()

            from fetch import main
            main()
def result():
    if request.method == 'POST':
        global query
        global resultlist
        query = request.form['query']
        if query not in dirwalk.showslist():
            resultlist = fetch.main(query)
        else:
            df = pd.read_csv('data/' + query + '.csv')
            resultlist.append(len(df))
            df["polarity"] = pd.to_numeric(df["polarity"], errors='coerce')
            df["subjectivity"] = pd.to_numeric(df["subjectivity"],
                                               errors='coerce')
            resultlist.append(df["polarity"].mean())
            resultlist.append(df['subjectivity'].mean())
            if float(resultlist[1]) > 0:
                resultlist.append('Positive')
            elif float(resultlist[1]) == 0:
                resultlist.append('Neutral')
            else:
                resultlist.append('Negative')
    return render_template("result.html",
                           query=query,
                           tweets_count=resultlist[0],
                           avgpol=resultlist[1],
                           avgsub=resultlist[2],
                           pol=resultlist[3])
 def call_script(self, root, username, password):
   try:
     #Disable all the buttons
     self.button.config(state='disabled')
     self.slogan.config(state='disabled')
     #Resetting messages
     self.message2['text'] = ""
     self.message3['text'] = ""
     self.message2['fg'] = 'blue'
     self.message3['fg'] = 'blue'
     #Perform the task
     data=fetch.main()
     #data = ['940773', '-----BEGIN CERTIFICATE-----\nsdasdasdasda\n-----END CERTIFICATE-----']
     if len(data) == 2:
       if data[0] == constants.FAILURE_MSG_FROM_FETCH or data[1] == constants.FAILURE_MSG_FROM_FETCH:
         self.message2['text'] = constants.CERT_FETCH_FAILURE_MSG
         self.message2['fg'] = 'red'
       else:
         #Checking format of certificate
         cert_validation = False
         cert_validation = self.validate_cert(data[1])
         if cert_validation is True:
           self.message2['text'] = constants.CERT_FETCH_SUCCESS_MSG + data[0]
           self.message3['text'] = constants.CERT_UPDATE_IN_PROGESS
           self.message3['fg'] = 'black'
           #Call Symportal REST API for updating Certificate
           url= constants.URL_UPDATE_CERT + data[0]
           payload = {'certificate' : data[1]}
           response=requests.put(url, auth=(username, password), data = payload)
           if response.status_code == 200:
             self.message3['text'] = constants.CERT_UPDATE_SUCCESS_MSG
             self.message3['fg'] = 'blue'
           else:
             self.message3['text'] = constants.CERT_UPDATE_FAILURE_MSG                
             self.message3['fg'] = 'red'
         else:
           self.message2['text'] = constants.CERT_INVALID_MSG 
           self.message2['fg'] = 'red'
           self.message3['text'] = constants.CERT_UPDATE_FAILURE_MSG
           self.message3['fg'] = 'red'
     else:
       self.message2['text'] = constants.CERT_FETCH_FAILURE_MSG
       self.message2['fg'] = 'red'
     #Enable all the buttons
     self.button.config(state='active')
     self.slogan.config(state='active')
   except Exception as e:
     self.message2['text'] = constants.GENERAL_ERROR_MSG
     self.message3['text'] = ""
Exemple #6
0
    def field_set(self, text):
        self.field.setText(text)
        if text == '--Select an option--':
            self.progress.hide()

        elif text == 'Motion Sensor':
            self.progress.show()
            self.loading()
            self.field2.show()

            from fetch import main
            val = main()
            if (val == 1):
                self.palette.setColor(QPalette.Foreground, Qt.red)
                self.field5.setText(
                    'Intruder has been detected! Please notify all users and defend the server!'
                )
                self.field5.setPalette(self.palette)
                self.field5.show()
            else:
                self.palette.setColor(QPalette.Foreground, Qt.green)
                self.field5.setText('Server is completely secure.')
                self.field5.setPalette(self.palette)
                self.field5.show()
Exemple #7
0
#! /usr/bin/env python
# coding=utf-8
'''
#=============================================================================
#     FileName: main.py
#         Desc: 抓取川大体测系统的数据并存档。直接运行此文件即可。
#       Author: Alsotang
#        Email: [email protected]
#     HomePage: http://tangzhan.li
#      Version: 0.0.1
#   LastChange: 2011-11-09 22:27:40
#      History:
#=============================================================================
'''

import fetch

if __name__ == '__main__':
    fetch.main()
Exemple #8
0
 def insert_quote(self):
         self.ui.textBrowser.setHtml(fetch.main())
Exemple #9
0
from pyramid.response import Response
from pyramid.view import view_config
from pyramid import request
from pyramid.view import view_defaults
import pyramid.view
import fetch
import crawl
import itertools
import operator
import datetime

#crawl.main()
tuple_date = fetch.main()

def grouper(n, iterable, fillvalue=None):
    "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
    args = [iter(iterable)] * n
    return itertools.izip_longest(fillvalue=fillvalue, *args)

date_lista = list(grouper(3,tuple_date))
lista_sortata = sorted(date_lista, key = operator.itemgetter(0))

data_curenta = datetime.date.today()

primul_entry = lista_sortata[0]
curs_minim = 4444
curs_maxim = 0

lista_noua = []

for i in lista_sortata :
Exemple #10
0
def checkit(log):
    """Perform pre-flight checks.  Messages are written to log, which
    could reasonably be something like sys.stderr.
    """

    def missing_input(name):
        """Complain about a missing input file."""

        log.write('MISSING: input/%s\n' % name)

    def missing_config(name):
        """Complain about a missing config file."""

        log.write('MISSING: config/%s\n' % name)

    def missing_file(name):
        for suffix in ['', '.gz']:
            if input_ok(name+suffix):
                return False
        return True

    def missing_files(names):
        """Check list of names and return missing ones.  Compression
        extensions (.gz) are also tried if supplied name is not found.
        Each name can be a string or a list of strings; if a list of
        strings then any string will do, and the first string will be
        returned if none are present.
        """

        missing = []
        for item in names:
            if isinstance(item, str):
                if missing_file(item):
                    # Didn't find file, even trying compressed suffixes.
                    missing_input(item)
                    missing.append(item)
            else:
                assert isinstance(item, list)
                for name in item:
                    if not missing_file(name):
                        break
                else:
                    missing_input(item[0])
                    missing.append(item[0])
        return missing

    rc = 0

    step0 = """
        antarc1.list
        antarc1.txt
        antarc2.list
        antarc2.txt
        antarc3.list
        antarc3.txt
        t_hohenpeissenberg_200306.txt_as_received_July17_2003
        ushcn2.tbl
        ushcnV2_cmb.tbl
        """.split()
    step1 = """
        mcdw.tbl
        ushcn2.tbl
        sumofday.tbl
        v2.inv
        """.split()
    step4 = """
    oisstv2_mod4.clim.gz
    """.split()

    ushcn_alternatives = """
        ushcnv2
        9641C_201003_F52.avg
        9641C_201002_F52.avg
        9641C_200907_F52.avg
        """.split()

    step0big = 'v2.mean'.split() + [ushcn_alternatives]
    step5big = 'SBBX.HadR2'.split()
    big = step0big + step5big
    assert big
    all = step0 + step1 + step4 + big
    missing = missing_files(all)
    if missing:
        log.write('Attempting to fetch missing files: %s\n' %
            ' '.join(missing))
        # Call fetch.py as if it were a program.
        import fetch
        fetch.main(argv=['fetch'] + missing)
        missing = missing_files(all)
        if missing:
            log.write("PROBLEM: Tried fetching missing files but it didn't work.\n")
            rc = max(rc, 2)
        else:
            log.write('OK: Fetching missing files looks like it worked\n')

    step1_config = """
        combine_pieces_helena.in
        Ts.strange.RSU.list.IN
        Ts.discont.RS.alter.IN
        """.split()
    for name in step1_config:
        if not config_ok(name):
            missing_config(name)
            rc = max(rc, 2)

    return rc
def api():
    return fetch.main()