0
votes

You won´t be able to run the script, sadly I don´t know why. It's about EOL but I'm not that much into python so I need your help, I´ve tried different stuff and didn't work. Also, my friend that actually is into phyton tried and failed.

this is just a menu code for running multiple antiviruses whenever I want to check my computer

import sys, string, os, arcgisscripting
def menu():
    print ("Welcome To S1MPL3 MENU, an simple made antivirus for open Wi-Fi and Computer Repair.\n 1. Easy File Check \n 2.Total Time Security \n 3.Suspicius Ip Check")
    choice = input()

    if choice == "1":
        print("Checking Files ... (The process wont take long !")
        os.chdir 'C:\Users\alexa\Desktop\Core_Files\Projects\S1mpl3 Antivirus\Check\Files\File_Check.vbs\
        menu()

    if choice == "2":
        print("TTS Chosen!")
        os.chdir  'C:\Users\alexa\Desktop\Projects\S1mpl3_Antivirus\Check\\Files\Ip_Check\'
        menu()

    if  choice == "3":
         print("Checking For Suspicius Ip in your Home Wi-Fi")
         os.chdir 'C:\Users\alexa\Desktop\Core_Files\Projects\S1mpl3 Antivirus\Check\Files\Ip_Check\'
         menu()

menu()

The error should be in the S1m of choice 2

Error: Syntax Error EOL while scanning string literal

3

3 Answers

1
votes

You are using backslash characters '\' in your paths. While this is OK on the command line, it is (mostly) not correct in source code. The backslash character is used as escape character to change the meaning of the following character. In your case the trailing apostroph is escaped so that the path string is not closed.

You can use a raw string like @RonaldAaronson proposed:

r'C:\Users\alexa\Desktop\Projects\S1mpl3_Antivirus\Check\Files\Ip_Check\'

Or replace all single backslash with double like this:

'C:\\Users\\alexa\\Desktop\\Projects\\S1mpl3_Antivirus\\Check\\Files\\Ip_Check\\'

Many Windows function also work with the unixoid path separator '/', and os.chdir() does so, too:

os.chdir('C:/Users/alexa/Desktop/Projects/S1mpl3_Antivirus/Check/Files/Ip_Check')

The library os has os.sep and os.altsep that are pathname separators. Use these to write better portable code. Please read the documentation. This is always a good idea.

Second observation: You need to call os.chdir() with parentheses.

0
votes

You are missing a single quote at the end of the line:

if choice == "1":
        print("Checking Files ... (The process wont take long !")
        os.chdir 'C:\Users\alexa\Desktop\Core_Files\Projects\S1mpl3 Antivirus\Check\Files\File_Check.vbs\   **<---here**
        menu()
0
votes

I have a similar problem while opening a directory. I used raw string and double backslashes and it works. Example:

os.chdir(r"C:\\Users\\alexa\Desktop\\Core_Files\\Projects\\S1mpl3Antivirus\\Check\\Files\\")