Exemple #1
0
 def Initialize(self, lst=None, silent=False):
     """ドライブ情報を取得し、リストを初期化する。"""
     self.log.debug("Getting drives list...")
     self.rootDirectory = ""
     t = misc.Timer()
     if isinstance(
             lst, list
     ):  # パラメータがリストなら、browsableObjects のリストとして処理刷る(ファイルリストを取得しないでコピーする)
         self._copyFromList(lst)
         return errorCodes.OK
     # end copy
     self.drives.clear()
     self.unusableDrives.clear()
     self.networkResources.clear()
     if not silent:
         globalVars.app.say(_("ドライブ洗濯"))
     drv = win32api.GetLogicalDrives()
     check = 1
     for i in range(26):
         if drv & check:
             self.Append(i)  # ドライブ検出
         check <<= 1
     # end ドライブ25個分調べる
     # ネットワークリソースの追加はタブ側から来ることになった
     self.log.debug("Drives list created in %d seconds." % t.elapsed)
     self.log.debug("%d drives and %d unusableDrives found." %
                    (len(self.drives), len(self.unusableDrives)))
     self.log.debug("Triggering sorting")
     self.ApplySort()
     return errorCodes.OK
Exemple #2
0
    def OnDriveButton(self, event):  #drive button handler
        #//show popup menu with all available drives/mount points
        menu = CPopupMenu()

        #ifdef __WXMSW__
        dwDrives = win32api.GetLogicalDrives()
        #print dwDrives
        #dwDrives   = ::GetLogicalDrives();
        nDriveIdx = 0

        while (nDriveIdx < 26):
            if (dwDrives & 1):
                #TODO (linux): TOMAKEBETTER
                szDrive = chr(ord('A') + nDriveIdx) + ':'
                #szDrive[0] = 'A' + chr (nDriveIdx)
                menu.Append(nDriveIdx + 1, szDrive)
            nDriveIdx += 1
            dwDrives >>= 1
        #wxpython
        self.PopupMenuXY(menu, 0, 20)
        nID = menu.GetSelectedID()
        if nID > 0:
            szDrive = chr(ord('A:') + nID - 1)

            #//make sure we have proper VFS
            while (self.m_pFileList.m_pVfs.GetType() != Vfs_LOCAL):
                wxGetApp().GetFrame().g_VfsManager.VfsStackPop(m_pFileList)

            self.m_pFileList.SetDirectory(szDrive)
 def getDisksUsage(self):
     usages = list()
     try:
         drives_mask = win32api.GetLogicalDrives()
         path = 'a'
         while drives_mask > 0:
             path_name = path + ':\\'
             if (drives_mask & 1):
                 try:
                     res = win32api.GetDiskFreeSpaceEx(path_name)
                     (free, total) = res[:2]
                     fs = win32api.GetVolumeInformation(path_name)[4]
                     used = total - free
                     usages.append({
                         'path': path_name,
                         'fs': fs,
                         'total': total,
                         'used': used
                     })
                 except:
                     pass
             drives_mask >>= 1
             path = chr(ord(path) + 1)
     except:
         logging.exception("Error retrieving disks usages.")
     return usages
    def get_drivers(self):
        """ 获取所有的驱动器 """
        drives = []
        bitmask = win32api.GetLogicalDrives()
        for letter in string.ascii_uppercase:
            if bitmask & 1:
                letter += ':/'
                drives.append(letter)
                self.get_disk(letter)
            bitmask >>= 1

        return drives
Exemple #5
0
    def FindHandhelds(self):
        #Retrieve all drives
        mask = win32api.GetLogicalDrives()

        #Convert drive mask to letters/drives
        drives = []
        for i in range(int(math.log(mask, 2)) + 1):
            driveExists = bool(mask & 1 << i)
            if driveExists:
                letter = chr(ord('A') + i)
                drives.append(r'\\.\%s:' % letter)

        #Make each drive into a potential handheld
        handheldCandidates = [Handheld(x) for x in drives]

        #Only get the drives which are actual handhelds
        validHandhelds = [x for x in handheldCandidates if x.IsHandheld()]

        return validHandhelds
Exemple #6
0
    F = api.GetDiskFreeSpace(disk + ":")
    rest = F[0] * F[1] * F[2] / 1e9
    total = F[0] * F[1] * F[3] / 1e9
    print("Rest:", rest, "G", "Total:", total, "G")
print(api.GetComputerName())
print(api.GetConsoleTitle())
print(api.GetCommandLine())
print(api.GetCursorPos())
print(api.GetDomainName())
print(api.GetEnvironmentVariable('path'))
print(api.GetFileAttributes('.'))
print(api.GetFileVersionInfo('C:\\windows\\system32\\cmd.exe', "\\"))
print(api.GetFullPathName('.'))
print(api.GetLocalTime())
print(api.GetLogicalDriveStrings().replace('\x00', ' '))
print(api.GetLogicalDrives())
print(api.GetLongPathName('C:'))
print(api.GetModuleFileName(0))
print(api.GetNativeSystemInfo())
print(hex(api.GetSysColor(con.COLOR_WINDOW)))
print(api.GetSystemDirectory())
print(api.GetSystemInfo())
print(api.GetSystemMetrics(con.SM_CXSCREEN))
print(api.GetSystemTime())
print(api.GetTickCount())
# print(api.GetTimeZoneInformation())
print(api.GetUserDefaultLangID())
print(api.GetUserName())
print(api.GetVersion())
print(api.GetVolumeInformation('C:'))
print(api.GetWindowsDirectory())
Exemple #7
0
    def list_available(filesystems=None):
        """
        Get the available drives

        Returns a tupple: (disk, mountpoint)
        """
        drives = []
        if Config().PLATFORM == 'win32':
            try:
                # Windows method
                import string
                import win32api
                import win32file
                bitmask = win32api.GetLogicalDrives()
                for letter in string.ascii_uppercase:
                    if bitmask & 1:
                        drive_type = win32file.GetDriveType(
                            '{}:\\'.format(letter))
                        if drive_type in [win32file.DRIVE_FIXED]:
                            if filesystems:
                                if win32api.GetVolumeInformation(
                                        '{}:\\'.format(
                                            letter))[4] in filesystems:
                                    drives.append((r'\\.\{}:'.format(letter),
                                                   '{}:\\'.format(letter)))
                            else:
                                drives.append((r'\\.\{}:'.format(letter),
                                               '{}:\\'.format(letter)))
                    bitmask >>= 1
                return drives
            except ImportError:
                pass
        elif Config().PLATFORM == 'unix':
            if PlatformData('unix').get_data().get('osversion') == 'osx':
                try:
                    # OSX method
                    import plistlib
                    from sh import diskutil
                    data = plistlib.loads(diskutil('list', '-plist').stdout)
                    for item in data.get('AllDisksAndPartitions', []):
                        mountpoint = item.get('MountPoint')
                        if not mountpoint:
                            continue  # Ignore not mounted file systems
                        if filesystems and not item.get('Content').split(
                                '_')[-1] in filesystems:
                            continue
                        drives.append(
                            ('/dev/r{}'.format(item['DeviceIdentifier']),
                             mountpoint))
                    return drives
                except (ImportError, ValueError):
                    pass
        try:
            # Linux and Android method
            with open('/proc/mounts') as ifile:
                for lines in ifile.readlines():
                    infos = lines.split(' ')
                    if not infos[0].startswith('/'):
                        continue  # Don't scan virtual file systems
                    if filesystems and not infos[2] in filesystems:
                        continue
                    drives.append((infos[0], infos[1]))
        except FileNotFoundError:
            pass

        if Config().PLATFORM == 'android':
            drives.append(('/sdcard', '/sdcard'))

        return drives
def _get_discs_count():
    return win32api.GetLogicalDrives()