Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowsError at /abc/ [Error 2] The system cannot find the file specified: '/media/user_folder' #9

Open
Hiieu opened this issue Jan 25, 2015 · 2 comments

Comments

@Hiieu
Copy link

Hiieu commented Jan 25, 2015

After trying typing in browser /abc/ url

Exception Type: WindowsError
Exception Value: [Error 2] The system cannot find the file specified: '/media/user_folder'
Exception Location: C:\myproject\filemanager\__init__.py in directory_structure, line 210
#filemanager/__init__.py

  def directory_structure(self):
    self.idee = 0
    dir_structure = {'':{'id':self.next_id(),'open':'yes','dirs':{},'files':[]}}
    os.chdir(self.basepath)  #<-----line 210
    for directory,directories,files in os.walk('.'):
      directory_list = directory[1:].split('/')
      current_dir = None
      nextdirs = dir_structure
      for d in directory_list:
        current_dir = nextdirs[d]
        nextdirs = current_dir['dirs']
      if directory[1:]+'/' == self.current_path:
        self.current_id = current_dir['id']
      current_dir['dirs'].update(dict(map(lambda d:(d,{'id':self.next_id(),'open':'no','dirs':{},'files':[]}),directories)))
      current_dir['files'] = files
    return dir_structure
@shhaumb
Copy link
Member

shhaumb commented Jan 25, 2015

The errors are because I've hardcoded the os path separator which is '/' in linux but '' in windows.
Can you change the code by using os.sep instead of '/' and os.path.join instead of simply string concatenation with '/' and check if it's working on windows correctly? If things get right, then open a pull request , I'll add the changes. Thanks.

@rohithasrk
Copy link
Contributor

@dhruvkb: Solved this while setting up and shall we pushing soon. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants