Python win32con.FILE_ATTRIBUTE_NORMAL Examples

The following are 9 code examples of win32con.FILE_ATTRIBUTE_NORMAL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module win32con , or try the search function .
Example #1
Source File: win32.py    From multibootusb with GNU General Public License v2.0 6 votes vote down vote up
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) 
Example #2
Source File: testShell.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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) 
Example #3
Source File: HID.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #4
Source File: win32.py    From multibootusb with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #5
Source File: document.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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 
Example #6
Source File: testShell.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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) 
Example #7
Source File: test_PasswordSettingsManager.py    From ctSESAM-python-memorizing with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #8
Source File: main.py    From MouseTracks with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #9
Source File: 構建.py    From Librian with Mozilla Public License 2.0 5 votes vote down vote up
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)