当前位置: 首页>>代码示例>>Python>>正文


Python win32file.FILE_ATTRIBUTE_NORMAL属性代码示例

本文整理汇总了Python中win32file.FILE_ATTRIBUTE_NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Python win32file.FILE_ATTRIBUTE_NORMAL属性的具体用法?Python win32file.FILE_ATTRIBUTE_NORMAL怎么用?Python win32file.FILE_ATTRIBUTE_NORMAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在win32file的用法示例。


在下文中一共展示了win32file.FILE_ATTRIBUTE_NORMAL属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _OpenFileForRead

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def _OpenFileForRead(self, path):
        try:
            fhandle = self.fhandle = win32file.CreateFile(
                path,
                win32file.GENERIC_READ,
                win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE,
                None,
                win32file.OPEN_EXISTING,
                win32file.FILE_ATTRIBUTE_NORMAL,
                None)

            self._closer = weakref.ref(
                self, lambda x: win32file.CloseHandle(fhandle))

            self.write_enabled = False
            return fhandle

        except pywintypes.error as e:
            raise IOError("Unable to open %s: %s" % (path, e)) 
开发者ID:google,项目名称:rekall,代码行数:21,代码来源:win32.py

示例2: _OpenFileForWrite

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def _OpenFileForWrite(self, path):
        try:
            fhandle = self.fhandle = win32file.CreateFile(
                path,
                win32file.GENERIC_READ | win32file.GENERIC_WRITE,
                win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE,
                None,
                win32file.OPEN_EXISTING,
                win32file.FILE_ATTRIBUTE_NORMAL,
                None)
            self.write_enabled = True
            self._closer = weakref.ref(
                self, lambda x: win32file.CloseHandle(fhandle))

            return fhandle

        except pywintypes.error as e:
            raise IOError("Unable to open %s: %s" % (path, e)) 
开发者ID:google,项目名称:rekall,代码行数:20,代码来源:win32.py

示例3: open

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def open(self, name):
        """
        Direct open devices.

        :param name: Port name.
        :return: 0 on success
        """
        path = self.ports[name]['path']
        try:
            self.files[path] = win32file.CreateFile(path,
                                                    win32file.GENERIC_WRITE |
                                                    win32file.GENERIC_READ,
                                                    0,
                                                    None,
                                                    win32file.OPEN_EXISTING,
                                                    win32file.FILE_ATTRIBUTE_NORMAL,
                                                    None)
        except win32file.error as exc_detail:
            print("%s\nFAIL: Failed open file %s" % (str(exc_detail), name))
            return exc_detail
        print("PASS: All files opened correctly.") 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:23,代码来源:virtio_console_guest.py

示例4: CreateFile

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def CreateFile(self, fname, mode="r", bufsize=-1):
        "Open a file the same way a File Directory migration engine would."
        fname = cygwin2nt(fname)
        UserLog.msg("CreateFile", fname)
        if mode == "r":
            wmode = win32file.GENERIC_READ
        elif mode == "w":
            wmode = win32file.GENERIC_WRITE
        elif mode in ( 'r+', 'w+', 'a+'):
            wmode = win32file.GENERIC_READ | win32file.GENERIC_WRITE
        else:
            raise ValueError, "invalid file mode"
        h = win32file.CreateFile(
            fname,                           #  CTSTR lpFileName,
            wmode,                           #  DWORD dwDesiredAccess,
            win32file.FILE_SHARE_DELETE | win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE, #  DWORD dwShareMode,
            None,                            #  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
            win32file.OPEN_EXISTING,         #  DWORD dwCreationDisposition,
            win32file.FILE_ATTRIBUTE_NORMAL, #  DWORD dwFlagsAndAttributes,
            0,                               #  HANDLE hTemplateFile
            )
        self._files[int(h)] = h
        return int(h) 
开发者ID:kdart,项目名称:pycopia,代码行数:25,代码来源:WindowsServer.py

示例5: rmtree

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def rmtree(self, path):
        path = cygwin2nt(path)
        for fname in os.listdir(path):
            file_or_dir = os.path.join(path, fname)
            if os.path.isdir(file_or_dir) and not os.path.islink(file_or_dir):
                self.rmtree(file_or_dir) #it's a directory reucursive call to function again
            else:
                try:
                    os.remove(file_or_dir) #it's a file, delete it
                except:
                    #probably failed because it is not a normal file
                    win32api.SetFileAttributes(file_or_dir, win32file.FILE_ATTRIBUTE_NORMAL)
                    os.remove(file_or_dir) #it's a file, delete it
        os.rmdir(path) #delete the directory here

    # os.path delegates 
开发者ID:kdart,项目名称:pycopia,代码行数:18,代码来源:WindowsServer.py

示例6: csv_export_ram

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def csv_export_ram(self):
        """Dump ram using winpmem"""
        hSvc = create_driver_service(self.logger)
        start_service(hSvc, self.logger)
        try:
            fd = win32file.CreateFile(
                "\\\\.\\pmem",
                win32file.GENERIC_READ | win32file.GENERIC_WRITE,
                win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE,
                None,
                win32file.OPEN_EXISTING,
                win32file.FILE_ATTRIBUTE_NORMAL,
                None)
            try:
                t = time.time()
                image = _Image(fd)
                self.logger.info("Imaging to " + self.output_dir + '\\' + self.computer_name + '_memdump.raw')
                image.DumpWithRead(self.output_dir + '\\' + self.computer_name + '_memdump.raw')
                self.logger.info("Completed in %s seconds" % (time.time() - t))
            finally:
                win32file.CloseHandle(fd)
        finally:
            stop_and_delete_driver_service(hSvc) 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:25,代码来源:dump.py

示例7: testFilePointer

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def testFilePointer(self):
        # via [ 979270 ] SetFilePointer fails with negative offset

        # Create a file in the %TEMP% directory.
        filename = os.path.join( win32api.GetTempPath(), "win32filetest.dat" )

        f = win32file.CreateFile(filename,
                                win32file.GENERIC_READ|win32file.GENERIC_WRITE,
                                0,
                                None,
                                win32file.CREATE_ALWAYS,
                                win32file.FILE_ATTRIBUTE_NORMAL,
                                0)
        try:
            #Write some data
            data = str2bytes('Some data')
            (res, written) = win32file.WriteFile(f, data)
            
            self.failIf(res)
            self.assertEqual(written, len(data))
            
            #Move at the beginning and read the data
            win32file.SetFilePointer(f, 0, win32file.FILE_BEGIN)
            (res, s) = win32file.ReadFile(f, len(data))
            
            self.failIf(res)
            self.assertEqual(s, data)
            
            #Move at the end and read the data
            win32file.SetFilePointer(f, -len(data), win32file.FILE_END)
            (res, s) = win32file.ReadFile(f, len(data))
            
            self.failIf(res)
            self.failUnlessEqual(s, data)
        finally:
            f.Close()
            os.unlink(filename) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:39,代码来源:test_win32file.py

示例8: GetFileAttributeFlags

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def GetFileAttributeFlags(self):
        return {
        "ARCHIVE":win32file.FILE_ATTRIBUTE_ARCHIVE,
        "COMPRESSED":win32file.FILE_ATTRIBUTE_COMPRESSED,
        "DIRECTORY":win32file.FILE_ATTRIBUTE_DIRECTORY,
        "HIDDEN":win32file.FILE_ATTRIBUTE_HIDDEN,
        "NORMAL":win32file.FILE_ATTRIBUTE_NORMAL,
        "OFFLINE":win32file.FILE_ATTRIBUTE_OFFLINE,
        "READONLY":win32file.FILE_ATTRIBUTE_READONLY,
        "SYSTEM":win32file.FILE_ATTRIBUTE_SYSTEM,
        "TEMPORARY":win32file.FILE_ATTRIBUTE_TEMPORARY,
        } 
开发者ID:kdart,项目名称:pycopia,代码行数:14,代码来源:WindowsServer.py

示例9: is_open

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def is_open(filename):
    handle = win32file.CreateFile(filename, win32file.GENERIC_READ, 0, None, win32file.OPEN_EXISTING,
                                  win32file.FILE_ATTRIBUTE_NORMAL, 0)
    if handle:
        return True
    else:
        return False 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:9,代码来源:utils.py

示例10: __init__

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def __init__(self, base, config, **kwargs):
        self.as_assert(base == None, 'Must be first Address Space')
        addrspace.AbstractRunBasedMemory.__init__(self, base, config, **kwargs)		

        self.fhandle = win32file.CreateFile(
            "\\\\.\\pmem",
            win32file.GENERIC_READ | win32file.GENERIC_WRITE,
            win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE,
            None,
            win32file.OPEN_EXISTING,
            win32file.FILE_ATTRIBUTE_NORMAL,
            None)
			
        self.ParseMemoryRuns() 
开发者ID:botherder,项目名称:volatility,代码行数:16,代码来源:win32pmem.py

示例11: init

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import FILE_ATTRIBUTE_NORMAL [as 别名]
def init(self, in_files):
        """
        Init and check port properties.
        """
        # This only sets the ports names and paths
        # TODO: symlinks are sometimes missing, use /dev/vport%dp%d"
        self.ports = self._get_port_status(in_files)

        # Check if all ports really exists
        remove = []
        for item in six.iteritems(self.ports):
            port = item[1]
            try:
                hFile = win32file.CreateFile(port['path'], 0, 0, None,
                                             win32file.OPEN_EXISTING,
                                             win32file.FILE_ATTRIBUTE_NORMAL,
                                             None)
                win32file.CloseHandle(hFile)
            except win32file.error:
                remove.append(port['name'])
                print("Fail to open port %s" % port['name'])
        for name in remove:
            del(self.ports[name])

        # Check if in_files count and system port count matches
        # TODO: Not all devices are listed
        # TODO: Find the way to list all devices
        if remove:
            print("FAIL: Not all ports are present, check the log.")
            return
        """
        reg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "System")
        reg = _winreg.OpenKey(reg, "CurrentControlSet")
        reg = _winreg.OpenKey(reg, "Services")
        reg = _winreg.OpenKey(reg, "VirtioSerial")
        reg = _winreg.OpenKey(reg, "Enum")
        virtio_port_count = _winreg.QueryValueEx(reg, "Count")[0]
        if virtio_port_count != len(self.ports):
            print("FAIL: Number of ports (%d) doesn't match the number"
                  " of ports in registry (%d)"
                  % (len(self.ports), virtio_port_count))
            return
        """

        print("PASS: Init and check virtioconsole files in system.") 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:47,代码来源:virtio_console_guest.py


注:本文中的win32file.FILE_ATTRIBUTE_NORMAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。