Esempio n. 1
0
    def run(self):
        while True:
            global wordcount

            is_dir = os.path.isdir(app_settings["document"])
            file_type = app_settings["document"].split(".")[-1]

            try:
                if is_dir:
                    wordcount = latexcountdir(app_settings["document"])
                elif file_type == "docx":
                    wordcount = countdocx(app_settings["document"])

                elif file_type == "tex":
                    wordcount = latexcount(app_settings["document"])


            except Exception as e:
                print "Count failed:"
                print e

            main.mainwindow.wordcount.setText(str(wordcount))

            print wordcount
            print file_type

            if app_settings["username"] == "yournamegoeshere":
                main.mainwindow.wordcount.setText("CHECK SETTINGS")
            elif not os.path.exists(app_settings["document"]):
                main.mainwindow.wordcount.setText("Invalid path")


            params = urllib.urlencode({'c': str(wordcount), 'name': app_settings["username"]})


            try:
                f = urllib.urlopen(app_settings["server_url"], params)
                print f.read()
            except Exception as e:
                print "Cannot comunicate with server"
                print e

            time.sleep(interval)
Esempio n. 2
0
def run():
    while True:
    
        count = 0
        
        if docx_file :
            count = countdocx(docx_file)
        else:
            args = [interpreter, count_script]
            count,error = subprocess.Popen(args,stdout = subprocess.PIPE,
                    stderr= subprocess.PIPE).communicate()
            if error:
                print "Error %s" % error
        
        params = urllib.urlencode({'c': str(count), 'name': name})
        
        try:
            f = urllib.urlopen(url, params)
            print f.read()
        except:
            print "Cannot communicate with server"
            
        time.sleep(interval)