Skip to content

Commit

Permalink
Operator Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Titov committed Mar 28, 2021
1 parent e0113af commit 31b9c63
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def data(self, index, role):
return library_path
elif role == Qt.ToolTipRole:
import os
return '{}\nFile size: {:.4f} MB'.format(library_path,
return '{}\nFile size: {:.3f} MB'.format(library_path,
os.stat(library_path).st_size / 1024. / 1024.)
elif role == Qt.DecorationRole:
return INSTALLED_ICON
Expand Down
10 changes: 5 additions & 5 deletions python2.7libs/houdini_tdk/operator_manager/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from ..widgets import FilterField
from ..fuzzy_proxy_model import FuzzyProxyModel
from ..utils import openFileLocation
from ..utils import openFileLocation, removePath
from .model import OperatorManagerLibraryModel, TextRole
from .view import OperatorManagerView

Expand All @@ -45,7 +45,7 @@ def repackHDA(library_path):
return

library_dir, name = os.path.split(library_path)
temp_repack_path = os.path.join(library_dir, 'temp_' + name.replace('.', '_'))
temp_repack_path = os.path.join(library_dir, 'temp_' + name)

try:
if os.path.isfile(library_path):
Expand All @@ -58,15 +58,15 @@ def repackHDA(library_path):
except hou.OperationFailed:
return
except OSError:
os.remove(temp_repack_path)
removePath(temp_repack_path)
return

try:
os.rename(temp_repack_path, library_path)
os.remove(backup_library_path)
removePath(backup_library_path)
except OSError:
os.rename(backup_library_path, library_path)
os.remove(temp_repack_path)
removePath(temp_repack_path)
return

hou.hda.reloadFile(library_path)
Expand Down
8 changes: 8 additions & 0 deletions python2.7libs/houdini_tdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import sys
import webbrowser
import shutil


def openFileLocation(file_path):
Expand All @@ -15,3 +16,10 @@ def openFileLocation(file_path):
subprocess.call('explorer /select,"{0}"'.format(file_path.replace('/', '\\')))
else:
webbrowser.open('file://' + os.path.dirname(file_path))


def removePath(path):
if os.path.isfile(path):
os.remove(path)
else:
shutil.rmtree(path, True)

0 comments on commit 31b9c63

Please sign in to comment.