本文整理汇总了Python中win32con.FILE_ATTRIBUTE_NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Python win32con.FILE_ATTRIBUTE_NORMAL属性的具体用法?Python win32con.FILE_ATTRIBUTE_NORMAL怎么用?Python win32con.FILE_ATTRIBUTE_NORMAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类win32con
的用法示例。
在下文中一共展示了win32con.FILE_ATTRIBUTE_NORMAL属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _openHandle
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def _openHandle(path, bWriteAccess, bWriteShare,
logfunc = lambda s: None):
TIMEOUT, NUM_RETRIES = 10, 20
for retry_count in range(6):
try:
access_flag = win32con.GENERIC_READ | \
(bWriteAccess and win32con.GENERIC_WRITE or 0)
share_flag = win32con.FILE_SHARE_READ | \
(bWriteShare and win32con.FILE_SHARE_WRITE or 0)
handle = win32file.CreateFile(
path, access_flag, share_flag, None,
win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL, None)
nth = { 0: 'first', 1:'second', 2:'third'}
logfunc("Opening [%s]: success at the %s iteration" %
(path, nth.get(retry_count, '%sth' % (retry_count+1))))
return handle
except pywintypes.error as e:
logfunc('Exception=>'+str(e))
if NUM_RETRIES/3 < retry_count:
bWriteShare = True
time.sleep(TIMEOUT / float(NUM_RETRIES))
else:
raise RuntimeError("Couldn't open handle for %s." % path)
示例2: testComplex
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def testComplex(self):
if sys.hexversion < 0x2030000:
# no kw-args to dict in 2.2 - not worth converting!
return
clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}")
ctime, atime, wtime = self._getTestTimes()
d = dict(cFileName="foo.txt",
clsid=clsid,
sizel=(1,2),
pointl=(3,4),
dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
ftCreationTime=ctime,
ftLastAccessTime=atime,
ftLastWriteTime=wtime,
nFileSize=sys_maxsize + 1)
self._testRT(d)
示例3: run
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def run(self):
#open file/device
try:
handle = win32file.CreateFile(
self.devicePath,
win32con.GENERIC_READ | win32con.GENERIC_WRITE,
win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,
None, # no security
win32con.OPEN_EXISTING,
win32con.FILE_ATTRIBUTE_NORMAL | win32con.FILE_FLAG_OVERLAPPED,
0
)
except pywintypes.error as (errno, function, strerror):
self.lockObject.release()
eg.PrintError(self.text.errorOpen + self.deviceName + " (" + strerror + ")")
return
示例4: findVolumeGuids
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def findVolumeGuids():
DiskExtent = collections.namedtuple(
'DiskExtent', ['DiskNumber', 'StartingOffset', 'ExtentLength'])
Volume = collections.namedtuple(
'Volume', ['Guid', 'MediaType', 'DosDevice', 'Extents'])
found = []
h, guid = FindFirstVolume()
while h and guid:
#print (guid)
#print (guid, win32file.GetDriveType(guid),
# win32file.QueryDosDevice(guid[4:-1]))
hVolume = win32file.CreateFile(
guid[:-1], win32con.GENERIC_READ,
win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,
None, win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL, None)
extents = []
driveType = win32file.GetDriveType(guid)
if driveType in [win32con.DRIVE_REMOVABLE, win32con.DRIVE_FIXED]:
x = win32file.DeviceIoControl(
hVolume, winioctlcon.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
None, 512, None)
instream = io.BytesIO(x)
numRecords = struct.unpack('<q', instream.read(8))[0]
fmt = '<qqq'
sz = struct.calcsize(fmt)
while 1:
b = instream.read(sz)
if len(b) < sz:
break
rec = struct.unpack(fmt, b)
extents.append( DiskExtent(*rec) )
vinfo = Volume(guid, driveType, win32file.QueryDosDevice(guid[4:-1]),
extents)
found.append(vinfo)
guid = FindNextVolume(h)
return found
示例5: MakeDocumentWritable
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def MakeDocumentWritable(self):
pretend_ss = 0 # Set to 1 to test this without source safe :-)
if not self.scModuleName and not pretend_ss: # No Source Control support.
win32ui.SetStatusText("Document is read-only, and no source-control system is configured")
win32api.MessageBeep()
return 0
# We have source control support - check if the user wants to use it.
msg = "Would you like to check this file out?"
defButton = win32con.MB_YESNO
if self.IsModified():
msg = msg + "\r\n\r\nALL CHANGES IN THE EDITOR WILL BE LOST"
defButton = win32con.MB_YESNO
if win32ui.MessageBox(msg, None, defButton)!=win32con.IDYES:
return 0
if pretend_ss:
print "We are only pretending to check it out!"
win32api.SetFileAttributes(self.GetPathName(), win32con.FILE_ATTRIBUTE_NORMAL)
self.ReloadDocument()
return 1
# Now call on the module to do it.
if self.scModule is None:
try:
self.scModule = __import__(self.scModuleName)
for part in self.scModuleName.split('.')[1:]:
self.scModule = getattr(self.scModule, part)
except:
traceback.print_exc()
print "Error loading source control module."
return 0
if self.scModule.CheckoutFile(self.GetPathName()):
self.ReloadDocument()
return 1
return 0
示例6: testUnicode
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def testUnicode(self):
# exercise a bug fixed in build 210 - multiple unicode objects failed.
if sys.hexversion < 0x2030000:
# no kw-args to dict in 2.2 - not worth converting!
return
ctime, atime, wtime = self._getTestTimes()
d = [dict(cFileName="foo.txt",
sizel=(1,2),
pointl=(3,4),
dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
ftCreationTime=ctime,
ftLastAccessTime=atime,
ftLastWriteTime=wtime,
nFileSize=sys_maxsize + 1),
dict(cFileName="foo2.txt",
sizel=(1,2),
pointl=(3,4),
dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
ftCreationTime=ctime,
ftLastAccessTime=atime,
ftLastWriteTime=wtime,
nFileSize=sys_maxsize + 1),
dict(cFileName=u"foo\xa9.txt",
sizel=(1,2),
pointl=(3,4),
dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
ftCreationTime=ctime,
ftLastAccessTime=atime,
ftLastWriteTime=wtime,
nFileSize=sys_maxsize + 1),
]
s = shell.FILEGROUPDESCRIPTORAsString(d, 1)
d2 = shell.StringAsFILEGROUPDESCRIPTOR(s)
# clobber 'dwFlags' - they are not expected to be identical
for t in d2:
del t['dwFlags']
self.assertEqual(d, d2)
示例7: tearDown
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def tearDown(self):
file = os.path.expanduser('~/.ctSESAM_test.pws')
if os.path.isfile(file):
try:
import win32con
import win32api
win32api.SetFileAttributes(file, win32con.FILE_ATTRIBUTE_NORMAL)
except ImportError:
pass
os.remove(file)
示例8: show_file
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def show_file(file_name):
"""Unset a file as hidden."""
try:
win32api.SetFileAttributes(file_name, win32con.FILE_ATTRIBUTE_NORMAL)
except win32api.error:
return False
return True
示例9:
# 需要导入模块: import win32con [as 别名]
# 或者: from win32con import FILE_ATTRIBUTE_NORMAL [as 别名]
def 構建工程(工程路徑, 標題, 圖標=None):
if 圖標:
subprocess.Popen(f'{此處}\\構建用\\ResourceHacker.exe -open {此處}\\構建用\\沒有窗口的虛僞的exe.exe -save {標題}.exe -action addoverwrite -res {圖標} -mask ICONGROUP,1,0')
else:
os.system(f'copy {此處}\\構建用\\沒有窗口的虛僞的exe.exe {標題}.exe')
if os.path.isfile(f'_{標題}.kuzu'):
win32api.SetFileAttributes(f'_{標題}.kuzu', win32con.FILE_ATTRIBUTE_NORMAL)
with open(f'_{標題}.kuzu', 'w') as f:
f.write(f'Librian.py --project "{工程路徑}"')
win32api.SetFileAttributes(f'_{標題}.kuzu', win32con.FILE_ATTRIBUTE_HIDDEN)