0

I have a script that I was writing only having Unix/Mac OS in mind.

Among other things, it is storing files on a given folder

data_path = config.data_path

os.chdir(data_path)
testfile = urllib.URLopener()
try:

    local_size = 0
    remote_size = int(urllib.urlopen(remote_name).headers['Content-Length'])
    if os.path.exists(data_path + temp_zip_name):
        local_size = pathlib.Path(data_path + temp_zip_name).stat().st_size
    if  local_size != remote_size:
        print 'downloading ' + temp_zip_name
        testfile.retrieve(remote_name, temp_zip_name)
        #local_size = pathlib.Path(data_path + filename).stat().st_size
    else:
        print 'skipping ' + temp_zip_name

Given that I was coming from UNIX, the data_path has the value

>>> data_path
Out[3]: '/data/cew/'

Interestingly, the script still is working under windows. My files are there as expected:

>>> os.listdir('/data/cew')
Out[9]: 
['2005.annual.singlefile.csv',
 '2005.csv',
 '2005.zip',
 '2005_filtered.csv',
 '2006.annual.singlefile.csv',
 '2006.csv',
 '2006.zip',
 '2006_filtered.csv']

However, I have no clue where that is. Is Python saving these somewhere in my user directory? Naturally, this folder doesnt exist. Trying to cd /data/cew gave me an error in Windows' cmd.

FooBar
  • 15,724
  • 19
  • 82
  • 171
  • It's almost certainly `C:/data/cew`. – Martijn Pieters Jul 16 '15 at 08:35
  • @MartijnPieters It is. Is that because `C:` comes first in the list of drives, because it is the WINDOWS drive, or how can I expect this to work on other Windows based systems? – FooBar Jul 16 '15 at 08:37
  • I'm not sure; I don't use Windows much. Perhaps [Find System Hard Disk Drive from Python?](http://stackoverflow.com/q/4006730) – Martijn Pieters Jul 16 '15 at 08:55
  • `/data/cew` is an absolute but not fully-qualified path in Windows. The system resolves it fully by using the drive or network share of the current working directory. The API also converts the forward slashes to backslashes for you. – Eryk Sun Jul 16 '15 at 15:59
  • @eryksun I feel that this is a satisfying answer. – FooBar Jul 16 '15 at 16:00

1 Answers1

0

Should be C:/data/cew. Have you checked?

sinhayash
  • 2,693
  • 4
  • 19
  • 51