Python script files no long run after migration to a new server


#1

I use the Cloud9 Educational plan and have a number of students signed up and using it.

After the Christmas break, when they opened their workspace, they were all greeted with a message saying that the workspace was “being migrated to a new server to ensure optimal performance”. This completed and the workspace opened without issue. Now they can open their Python scripts but, when they try to run them, they get this error (from my own workspace which has the same issue):
python2: can't open file '/home/ubuntu/workspace/Chapter': [Errno 2] No such file or directory

I quickly realised where the problem is. In this case, the full path to the script is:
/home/ubuntu/workspace/Chapter 1/ex1.py

Note the space after ‘/Chapter’. Accordingly, in the console tab, the Command is:
Chapter\ 1/ex1.py

The space is escaped. However, the error indicates that everything after ‘/Chapter’ has been removed. Which is why there is “no such file or directory”. If I remove the space from the directory name, the script runs.

So the problem is spaces in file names and directories. But this worked without issue before the workspace was migrated. Debates about the validity of spaces in file and directory names aside, I have a large number of students, many with a large number of directories or files, who currently can’t run their code without a lot of grunt work first.

Is their an easier solution than removing all the spaces manually?


#2

The solution is here: http://stackoverflow.com/questions/2709458/how-to-replace-spaces-in-file-names-using-a-bash-script

  1. Open a Terminal
  2. cd ../
  3. ls (check that you are one directory above /workspace)
  4. find workspace/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;

Use with caution.