[Python] ValueError: No closing quotation

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following code which returns the public IP's

    def gather_public_ip():
    ACCESS_KEY = config.get('aws','access_key')
    SECRET_KEY = config.get('aws','secret_key')
    regions = regions = ['us-west-2','eu-central-1','ap-southeast-1']
    # regions = config.get('aws','region').split(',')
    all_EIP = []
    for region in regions:
    client = boto3.client('ec2',aws_access_key_id=ACCESS_KEY,aws_secret_access_key=SECRET_KEY,region_name=region,)
    addresses_dict = client.describe_addresses()
    for eip_dict in addresses_dict['Addresses']:
    if 'PrivateIpAddress' in eip_dict:
    print eip_dict['PublicIp']
    # return str(eip_dict['PublicIp'])
    all_EIP.append(eip_dict['PublicIp'])
    print all_EIP
    # print str(all_EIP)
    return str(all_EIP)


    This is called and returned as :

    net_range = gather_public_ip()
    for ip in net_range:
    r = s.run(ip)


    run looks like :

    def run(self, targets="" ,options="-Pn"):
    #start a new nmap scan on localhost with some specific options

    syslog.syslog("Scan started")
    parsed = None
    nmproc = NmapProcess(targets,options)
    rc = nmproc.run()

    if rc != 0:
    syslog.syslog("nmap scan failed: {0}".format(nmproc.stderr))
    try:
    parsed = NmapParser.parse(nmproc.stdout)
    self.report = parsed
    except NmapParserException as e:
    syslog.syslog("Exception raised while parsing scan: {0}".format(e.msg))

    syslog.syslog("Scan complete")
    syslog.syslog("Scan duration: "+ str(parsed.elapsed))
    self.report = parsed
    return parsed


    after printing the list , this throws me :

    Traceback (most recent call last):
    File "portwatch.py", line 300, in <module>
    r = s.run(ip)
    File "portwatch.py", line 239, in run
    rc = nmproc.run()
    File "/usr/local/lib/python2.7/dist-packages/libnmap/process.py", line 257, in run
    else shlex.split(self.__nmap_command_line)
    File "/usr/lib/python2.7/shlex.py", line 279, in split
    return list(lex)
    File "/usr/lib/python2.7/shlex.py", line 269, in next
    token = self.get_token()
    File "/usr/lib/python2.7/shlex.py", line 96, in get_token
    raw = self.read_token()
    File "/usr/lib/python2.7/shlex.py", line 172, in read_token
    raise ValueError, "No closing quotation"
    ValueError: No closing quotation

    Continue reading...

Compartilhe esta Página