Skip to content

Commit

Permalink
Fix ZombieProcess error caused by psutil>= 3.0.0, fixes #315 and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed Dec 4, 2015
1 parent f6108ca commit e030b97
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions xlwings/_xlmac.py
Expand Up @@ -75,28 +75,34 @@ def is_file_open(fullname):
Checks if the file is already open
"""
for proc in psutil.process_iter():
if proc.name() == 'Microsoft Excel':
for i in proc.open_files():
path = i.path
if PY3:
if path.lower() == fullname.lower():
return True
else:
if isinstance(path, str):
path = unicode(path, 'utf-8')
# Mac saves unicode data in decomposed form, e.g. an e with accent is stored as 2 code points
path = unicodedata.normalize('NFKC', path)
if isinstance(fullname, str):
fullname = unicode(fullname, 'utf-8')
if path.lower() == fullname.lower():
return True
try:
if proc.name() == 'Microsoft Excel':
for i in proc.open_files():
path = i.path
if PY3:
if path.lower() == fullname.lower():
return True
else:
if isinstance(path, str):
path = unicode(path, 'utf-8')
# Mac saves unicode data in decomposed form, e.g. an e with accent is stored as 2 code points
path = unicodedata.normalize('NFKC', path)
if isinstance(fullname, str):
fullname = unicode(fullname, 'utf-8')
if path.lower() == fullname.lower():
return True
except psutil.NoSuchProcess:
pass
return False


def is_excel_running():
for proc in psutil.process_iter():
if proc.name() == 'Microsoft Excel':
return True
try:
if proc.name() == 'Microsoft Excel':
return True
except psutil.NoSuchProcess:
pass
return False


Expand Down

0 comments on commit e030b97

Please sign in to comment.