-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFbxUtils.py
More file actions
77 lines (66 loc) · 1.98 KB
/
FbxUtils.py
File metadata and controls
77 lines (66 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import os
import shutil
import stat
import subprocess
import time
import sys
import platform
# Utility functions to manipulate/walk disks
def FileExist(File):
if os.access(File,os.F_OK):
return 1
else:
return 0
def FileDelete(File):
try:
os.chmod(File, stat.S_IWRITE)
os.remove(File)
except:
raise
def DirCopy(Src,Dst):
if FileExist(Dst):
try:
Files = os.listdir(Src)
for File in Files:
if os.path.isdir(os.path.join(Src,File)):
DirCopy(os.path.join(Src,File), os.path.join(Dst,File) )
elif os.path.isfile(os.path.join(Src,File)):
FileCopy( os.path.join(Src,File), os.path.join(Dst,File) )
except:
raise (RuntimeError, "Can't copy directory %s to %s" % (Src, Dst))
else:
try:
shutil.copytree(Src, Dst)
except:
raise (RuntimeError,"Can't copy directory")
def DirCreate(Dir):
if not os.access(Dir,os.F_OK):
os.makedirs ( Dir )
def DirDelete(Dir):
if FileExist(Dir):
Files = os.listdir(Dir)
for File in Files:
full_path = os.path.join(Dir, File)
if os.path.isdir(full_path):
DirDelete(full_path)
elif os.path.isfile(full_path):
FileDelete(full_path)
os.chmod( Dir,stat.S_IWRITE )
os.rmdir(Dir)
# *************************************************************************
# Log utility
# 1 - Steps
# 2 - Steps + Low level details when errors
# 3 - Steps + Low level details when warnings
# 4 - Steps + High level details
# *************************************************************************
LogLevel = 3
def Log(Level,String,OutLogFile=None):
if Level<=LogLevel:
sys.stdout.write(String)
sys.stdout.flush()
if OutLogFile != None:
OutLogFile.write(String)
OutLogFile.flush()
def LogFlush():
sys.stdout.flush()