當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。