1

I am in the process of developing a troubleshooting application in Python that will allow a user to input a query. This query would contain the brand of the device and the issue or symptom of their problem. I am in the process of writing a script which essentially dissects the query to find an appropriate solution following keywords and brands of the device.

Current Code: #Import Modules import warnings

#Define Globals
brands = ["apple", "android", "windows"]
brand = ''

def Main():
    init()
    print("--Welcome to Troubleshooting Applet--")
    print("In your query please include the brand of your device and the problem / symptom of your current issue. \n")
    query = input("Enter your query: ").lower()
    brand = set(brands).intersection(query.split())
    if brand != '':
        print(brand)
    else:
        print("Brand in existance not defined")

def init():
    #warnings.filterwarnings("ignore") #Disable while debugging

if __name__ == '__main__':
    Main()

Currently, the script will identify a brand, but I am not certain on how to check for a wide number of keywords in order to follow a solution route. I would expect the solution to follow the pattern of having selected a brand a secondary array specific for the brand which would contain a number of potential errors. Each of these errors could have a solution defined.

I would appreciate any insight,

Thanks,

Sam

  • Hey I'm actually not good with Python. How can I get this running in my interpreter? I currently get this error message: "SyntaxError: multiple statements found while compiling a single statement". – lonious Aug 17 '16 at 20:14
  • Hey Gordlonious, I have been running this in Python Shell v3.5.2. I would expect that to be the most obvious error. Thank you for your help, it is most appreciated, Sam :-) – Sammy Herring Aug 17 '16 at 22:08

1 Answers1

0

Run this I hope this gives you some ideas. You need to fix your indentation for the main(): function.

#Define Globals
brands = ["apple", "android", "windows"]
brand = ''
import random
def Main():
        init()
        print("--Welcome to Troubleshooting Applet--")
        print("In your query please include the brand of your device and the problem / symptom of your current issue. \n")
        query = input("Enter your query: ").lower()
        brand = set(brands).intersection(query.split())
        keywords = ['custom security keywords collection', 'item2', 'key3']
        index = 0
        for i in range(len(query)):
            if query.__contains__(keywords[index]): # __iter__() # could use 'in' keyword here
                #switch/decide
                text = 'run decision'
                print(keywords[index])
            else:
                if len(keywords) < 3:
                    index = index + 1
                text1 = 'continue'
        # OR
        # Test keyword idea...
        tKeyword = random.choice(keywords)
        # You need a lot of work to come up with error decisions right?
        # You may need to start pulling from a Database and checking against large documents?
        # just trying to come up with something to get you going
        print ('RANDOM keyword for TESTING:' + tKeyword)
        if brand != '':
            print(brand)
        else:
            print("Brand in existance not defined")

def init():
        ftp = 0
    #warnings.filterwarnings("ignore") #Disable while debugging

if __name__ == '__main__':
    Main()
    print('ask yourself about escape sequences and encoding for the query? \+'
          ' I believe utf-8 is the default encoding for python 3')

def dbconnect():
    url = "http://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python"
    url1 = "https://docs.python.org/3/reference/datamodel.html#object.__contains__"
    url2 = "مرحبا I think python is very unicode friendly.."
lonious
  • 676
  • 9
  • 25
  • Python has a cool ftplib `ftplib` module that I am hoping will work with 'our' new servers. `from ftplib import FTP`. The documentation makes it seem very simple. On my first try I was unable to connect to my ftp site. However, the built-in external ftp for Windows 10 succeeded. `ftp ftp.url'. Then authentication. #today – lonious Aug 19 '16 at 22:25
  • Thank you - I will give it a try and get back to you! :-) – Sammy Herring Aug 19 '16 at 23:26
  • Hi gordlonious, I have reached this point - https://github.com/KentCoding/phoneTroubleshooting/blob/master/phoneTroubleshooting.py. I am now trying to setup a Keyword filtering system. But the error detection is now setup. What do you think so far? Sam – Sammy Herring Aug 20 '16 at 23:27
  • Also, I have opened up a new question which I believe may be a solution to the current issue - http://stackoverflow.com/questions/39059671/object-orientated-python-function-parameter-to-alter-variables – Sammy Herring Aug 20 '16 at 23:51