Python Forum
scan drives in windows from Cygwin
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
scan drives in windows from Cygwin
#1
Is it possible to get the windows drive names from Cygwin?

I have a requirement to get the windows drive names from Cygwin using a python program and create a folder in one of the directories.

I am using below program to scan the number of drives in windows and create a directory in one of the drives. It works fine , but would like to achieve the same behavior when running the program from Cygwin , since Cygwin is a Linux environment it gives error for
from ctypes import windll.
Following is code i am using.

import os
import string
from ctypes import windll

def get_drives():
    drives = []
    bitmask = windll.kernel32.GetLogicalDrives()
    for letter in string.uppercase:
        if bitmask & 1:
            drives.append(letter)
        bitmask >>= 1

    return drives
    
def create_temp_dir(drives):
    newpath = drives[0]+':\\temp'
    if not os.path.exists(newpath):
        print " creating ", newpath
        os.makedirs(newpath)

if __name__ == '__main__':
    drives = get_drives()
    print drives
    create_temp_dir(drives)
Reply
#2
see psutil: https://pypi.org/project/psutil/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python C Extension Module loading issue on Cygwin mesibo 0 646 Sep-22-2023, 05:41 AM
Last Post: mesibo
  Scan for Bluetooth device korenron 0 2,612 Jan-10-2022, 01:06 PM
Last Post: korenron
  Convert looping home security to a one time scan of switches and sensors duckredbeard 0 1,749 Dec-08-2020, 04:31 AM
Last Post: duckredbeard
  How to scan huge files and make it in chunks ampai 2 2,588 May-28-2020, 08:20 PM
Last Post: micseydel
  Receiving XML exception from nmap.scan() results. PythonNmap 4 4,091 Jan-21-2020, 04:41 AM
Last Post: PythonNmap
  Upload files to Google/Azure/AWS or cloud drives using python tej7gandhi 0 1,910 May-11-2019, 03:02 PM
Last Post: tej7gandhi
  Code doesn't loop after first RFID scan BadgerHack 5 4,266 May-01-2018, 11:07 AM
Last Post: BadgerHack
  Wifi.Scan thenewguy 0 2,352 Mar-24-2018, 05:59 PM
Last Post: thenewguy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020