Python win32api.SetFileAttributes() Examples
The following are 9
code examples of win32api.SetFileAttributes().
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
win32api
, or try the search function
.
Example #1
Source File: WindowsServer.py From pycopia with Apache License 2.0 | 6 votes |
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
Example #2
Source File: document.py From ironpython2 with Apache License 2.0 | 5 votes |
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 #3
Source File: WindowsServer.py From pycopia with Apache License 2.0 | 5 votes |
def SetFileAttributes(self, name, flags): name = cygwin2nt(name) return win32file.SetFileAttributes(name, flags)
Example #4
Source File: Lo0sR.py From Lo0sR with MIT License | 5 votes |
def create_hidden_folder(self): if os.path.exists(path_to_files): pass else: os.makedirs(path_to_files) win32api.SetFileAttributes(path_to_files, win32con.FILE_ATTRIBUTE_HIDDEN)
Example #5
Source File: preference_manager.py From ctSESAM-python-memorizing with GNU General Public License v3.0 | 5 votes |
def set_hidden(self): """ Hides the settings file if possible. """ try: import win32con import win32api win32api.SetFileAttributes(self.settings_file, win32con.FILE_ATTRIBUTE_HIDDEN) except ImportError: pass
Example #6
Source File: test_PasswordSettingsManager.py From ctSESAM-python-memorizing with GNU General Public License v3.0 | 5 votes |
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 #7
Source File: main.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
def hide_file(file_name): """Set a file as hidden.""" try: win32api.SetFileAttributes(file_name, win32con.FILE_ATTRIBUTE_HIDDEN) except win32api.error: return False return True
Example #8
Source File: main.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
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 |
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)