Azure-cli: az find ERROR

Created on 20 Apr 2017  路  12Comments  路  Source: Azure/azure-cli

az find -q function
'function' object has no attribute 'replace'
Traceback (most recent call last):
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/application.py", line 201, in execute
    result = expanded_arg.func(params)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 403, in _execute_command
    raise ex
AttributeError: 'function' object has no attribute 'replace'
bug

All 12 comments

@devigned when I try this query I get some interesting, icky errors:

Windows 10, cmd.exe, Python 3.5.1:

az find -q function
'charmap' codec can't encode character '\u201c' in position 289: character maps to <undefined>

Windows 10, cmd.exe, Python 2.7.11:

az find -q function
[Error 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\trpresco\\.azure\\search_index_v1\\_MAIN_1.toc'
Traceback (most recent call last):
  File "c:\users\trpresco\documents\github\azure-cli\src\azure-cli\azure\cli\main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "c:\users\trpresco\documents\github\azure-cli\src\azure-cli-core\azure\cli\core\application.py", line 201, in execute
    result = expanded_arg.func(params)
  File "c:\users\trpresco\documents\github\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 403, in _execute_command
    raise ex
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\trpresco\\.azure\\search_index_v1\\_MAIN_1.toc'

@spboyer could you provide Azure CLI version and environmental details?

@tjprescott I think your error is related to this http://stackoverflow.com/questions/25127935/unicodeencodeerror-charmap-codec-cant-encode-character-problems. After hitting that, it looks like the index reader is still left open. I'm not sure why. It would be awesome get a stack trace containing the offending line.

I tried to rerun it on Python 3 and I got a different, uglier message (but with a stack trace!):

az find -q function
[Errno 2] No such file or directory: 'C:\\Users\\trpresco\\.azure\\search_index_v1\\MAIN_nlgs8n27gp1666bq.seg'
Traceback (most recent call last):
  File "c:\users\trpresco\documents\github\azure-cli\src\azure-cli\azure\cli\main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "c:\users\trpresco\documents\github\azure-cli\src\azure-cli-core\azure\cli\core\application.py", line 201, in execute
    result = expanded_arg.func(params)
  File "c:\users\trpresco\documents\github\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 403, in _execute_command
    raise ex
  File "c:\users\trpresco\documents\github\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 398, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "c:\users\trpresco\documents\github\azure-cli\src\command_modules\azure-cli-find\azure\cli\command_modules\find\custom.py", line 128, in find
    with ix.searcher() as searcher:
  File "C:\Users\trpresco\Documents\github\azure-cli\env\lib\site-packages\whoosh\index.py", line 318, in searcher
    return Searcher(self.reader(), fromindex=self, **kwargs)
  File "C:\Users\trpresco\Documents\github\azure-cli\env\lib\site-packages\whoosh\index.py", line 557, in reader
    raise e
  File "C:\Users\trpresco\Documents\github\azure-cli\env\lib\site-packages\whoosh\index.py", line 548, in reader
    info.generation, reuse=reuse)
  File "C:\Users\trpresco\Documents\github\azure-cli\env\lib\site-packages\whoosh\index.py", line 529, in _reader
    return segreader(segments[0])
  File "C:\Users\trpresco\Documents\github\azure-cli\env\lib\site-packages\whoosh\index.py", line 524, in segreader
    generation=generation)
  File "C:\Users\trpresco\Documents\github\azure-cli\env\lib\site-packages\whoosh\reading.py", line 610, in __init__
    files = segment.open_compound_file(storage)
  File "C:\Users\trpresco\Documents\github\azure-cli\env\lib\site-packages\whoosh\codec\base.py", line 569, in open_compound_file
    dbfile = storage.open_file(name)
  File "C:\Users\trpresco\Documents\github\azure-cli\env\lib\site-packages\whoosh\filedb\filestore.py", line 504, in open_file
    f = StructFile(open(self._fpath(name), "rb"), name=name, **kwargs)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\trpresco\\.azure\\search_index_v1\\MAIN_nlgs8n27gp1666bq.seg'

@devigned

az --version
azure-cli (2.0.3+1.dev20170419)

acr (2.0.1+1.dev20170419)
acs (2.0.3+1.dev20170419)
appservice (0.1.2+dev)
batch (2.0.1+1.dev20170419)
cloud (2.0.1+1.dev20170419)
component (2.0.1+1.dev20170419)
configure (2.0.3+1.dev20170419)
container (0.1.3+1.dev20170419)
core (2.0.3+1.dev20170419)
documentdb (0.1.3+1.dev20170419)
feedback (2.0.1+1.dev20170419)
find (0.1.2rc1+1.dev20170312)
iot (0.1.3+1.dev20170419)
keyvault (2.0.1+1.dev20170419)
lab (0.0.2+1.dev20170419)
monitor (0.0.2+1.dev20170419)
network (2.0.3+1.dev20170419)
nspkg (2.0.0+1.dev20170419)
profile (2.0.3+1.dev20170419)
redis (0.2.0+1.dev20170419)
resource (2.0.3+1.dev20170419)
role (2.0.2+1.dev20170419)
sql (2.0.1+1.dev20170419)
storage (2.0.3+1.dev20170419)
vm (2.0.3+1.dev20170419)

Python (Darwin) 2.7.12 (default, Jun 29 2016, 14:05:02)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]

@tjprescott there are two issues with yours.

  1. When changing between py 2 and 3, whoosh encodes the indexes differently with pickle. We catch that ValueError and attempt to reindex. This is failing on Windows b/c a file lock is taken. When running with --reindex, this will wipe out the directory and all will be good.
  2. The issue with the charmap is caused b/c the storage SDK has some ugly documentation and I need to make our indexer / result printer more defensive. See the following:
`az storage message update`
    Updates the visibility timeout of a message. You can also use this
    operation to update the contents of a message.  This operation can
    be used to continually extend the invisibility of a  queue
    message. This functionality can be useful if you want a worker
    role  to 芒聙聹lease芒聙聺 a queue message. For example, if a worker
    role calls get_messages  and recognizes that it needs more time to
    process a message, it can  continually extend the message芒聙聶s
    invisibility until it is processed. If  the worker role were to
    fail during processing, eventually the message  would become
    visible again and another worker role could process it.  If the
    key-encryption-key field is set on the local service object, this
    method will encrypt the content before uploading.

I don't think @tjprescott's issue is related to @spboyer's issue.

@spboyer what happens if you run az find -q function --reindex?

@devigned

$ az find -q function --reindex
'function' object has no attribute 'replace'
Traceback (most recent call last):
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/application.py", line 201, in execute
    result = expanded_arg.func(params)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 403, in _execute_command
    raise ex
AttributeError: 'function' object has no attribute 'replace'
az --version
azure-cli (2.0.3+1.dev20170420)

acr (2.0.1+1.dev20170420)
acs (2.0.3+1.dev20170420)
appservice (0.1.3+1.dev20170420)
batch (2.0.1+1.dev20170420)
cloud (2.0.1+1.dev20170420)
component (2.0.1+1.dev20170420)
configure (2.0.3+1.dev20170420)
container (0.1.3+1.dev20170420)
core (2.0.3+1.dev20170420)
documentdb (0.1.3+1.dev20170420)
feedback (2.0.1+1.dev20170420)
find (0.1.2rc1+1.dev20170312)
iot (0.1.3+1.dev20170420)
keyvault (2.0.1+1.dev20170420)
lab (0.0.2+1.dev20170420)
monitor (0.0.2+1.dev20170420)
network (2.0.3+1.dev20170420)
nspkg (2.0.0+1.dev20170420)
profile (2.0.3+1.dev20170420)
redis (0.2.0+1.dev20170420)
resource (2.0.3+1.dev20170420)
role (2.0.2+1.dev20170420)
sql (2.0.1+1.dev20170420)
storage (2.0.3+1.dev20170420)
vm (2.0.3+1.dev20170420)

Python (Darwin) 2.7.12 (default, Jun 29 2016, 14:05:02)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
(az-cli-bash) shayneboyer @ ~/az-cli-bash/bin$
Error loading command module 'redis'
No module named mgmt.keyvault
Traceback (most recent call last):
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/application.py", line 201, in execute
    result = expanded_arg.func(params)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 404, in _execute_command
    reraise(*sys.exc_info())
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 399, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/command_modules/find/custom.py", line 97, in find
    _create_index()
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/command_modules/find/custom.py", line 59, in _create_index
    _index_help()
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/command_modules/find/custom.py", line 40, in _index_help
    for cmd, document in list(_cli_index_corpus().items()):
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/command_modules/find/custom.py", line 34, in _cli_index_corpus
    return build_command_table()
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/command_modules/find/_gather_commands.py", line 16, in build_command_table
    cmd_table[cmd].load_arguments()
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 207, in load_arguments
    self.arguments.update(self.arguments_loader())
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 443, in arguments_loader
    return extract_args_from_signature(get_op_handler(operation), no_wait_param=no_wait_param)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 341, in get_op_handler
    op = import_module(mod_to_import)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/command_modules/vm/custom.py", line 19, in <module>
    from azure.cli.command_modules.vm._validators import _get_resource_group_from_vault_name
  File "/Users/shayneboyer/az-cli-bash/lib/python2.7/site-packages/azure/cli/command_modules/vm/_validators.py", line 11, in <module>
    from azure.mgmt.keyvault import KeyVaultManagementClient
ImportError: No module named mgmt.keyvault

Yay! moar stack!

@johanste, this looks like the issue I ran into yesterday.

These are probably related: #2907

this should be resolved after a reinstall (delete directory and re-run curl script). Please reopen if you still see this

Was this page helpful?
0 / 5 - 0 ratings