path

Special characters in OSX filename ? (Python os.rename)

荒凉一梦 提交于 2020-01-04 14:10:15
问题 I am trying to rename some files automatically on OSX with a python script. But I fail to work with special characters like forward slash etc.: oldname = "/test" newname = "/test(1\/10)" os.rename(oldname, newname) I think I do have an encoding problem. But different tries with re.escape or using UTF-8 unicode encodings havent been successful for me. Would you have a hint? Thanks! Marco 回答1: What most of the file systems have in common is that they do not allow directory separators (slashes)

How to get original location of script used for SLURM job?

a 夏天 提交于 2020-01-04 13:35:10
问题 I'm starting the SLURM job with script and script must work depending on it's location which is obtained inside of script itself with SCRIPT_LOCATION=$(realpath $0) . But SLURM copies script to slurmd folder and starts job from there and it screws up further actions. Are there any option to get location of script used for slurm job before it has been moved/copied? Script is located in network shared folder /storage/software_folder/software_name/scripts/this_script.sh and it must to: get it's

PHP: Can include a file that file_exists() says doesn't exist

别来无恙 提交于 2020-01-04 13:23:25
问题 In my script, I set the include path (so another part of the application can include files too), check that a file exists, and include it. However, after I set the include path, file_exists() reports that the file does not exist, yet I can still include the same file. <?php $include_path = realpath('path/to/some/directory'); if(!is_string($include_path) || !is_dir($include_path)) { return false; } set_include_path( implode(PATH_SEPARATOR, array( $include_path, get_include_path() )) ); //

python setup.py install changes script interpreter

馋奶兔 提交于 2020-01-04 07:46:11
问题 I have a Python package that includes a few scripts in a scripts/ folder. My setup.py file includes:: #!/usr/bin/env python from distutils.core import setup scripts = ['script1', 'script2', 'script3'] setup(name='Test', version='0.1.0', packages=['test'], scripts=['scripts/' + x for x in scripts] ) Each script contains the line:: #!/usr/bin/env python at the top. However, when I run python setup.py install this line gets changed to:: #!/usr/bin/python automatically in the installed scripts.

What is the algorithm that finds the minimal highest cost of all edges?

久未见 提交于 2020-01-04 07:19:07
问题 I'm trying to solve a problem where I need to find the minimal cost per step to get from a start to a goal node. I think this algorithm exists, but I can not find the name of this algorithm. In the case I am working on there are only positive edges and there could be cycles. It is not dijkstra's, because I am not looking for the total minimum cost, but for a cost that represents the minimal highest cost of all the steps. In the following example this algorithm would thus output 3 as 3 is the

How can I get Python to find ffprobe?

强颜欢笑 提交于 2020-01-04 07:03:10
问题 I have ffmpeg and ffprobe installed on my mac (macOS Sierra), and I have added their path to PATH. I can run them from terminal. I am trying to use ffprobe to get the width and height of a video file using the following code: import subprocess import shlex import json # function to find the resolution of the input video file def findVideoResolution(pathToInputVideo): cmd = "ffprobe -v quiet -print_format json -show_streams" args = shlex.split(cmd) args.append(pathToInputVideo) # run the

How do I get in python the maximum filesystem path length in unix?

北城余情 提交于 2020-01-04 06:29:28
问题 In the code I maintain I run across: from ctypes.wintypes import MAX_PATH I would like to change it to something like: try: from ctypes.wintypes import MAX_PATH except ValueError: # raises on linux MAX_PATH = 4096 # see comments but I can't find any way to get the value of max filesystem path from python ( os, os.path, sys... ) - is there a standard way or do I need an external lib ? Or there is no analogous as MAX_PATH in linux, at least not a standard among distributions ? Answer try: MAX

How do I get in python the maximum filesystem path length in unix?

跟風遠走 提交于 2020-01-04 06:29:07
问题 In the code I maintain I run across: from ctypes.wintypes import MAX_PATH I would like to change it to something like: try: from ctypes.wintypes import MAX_PATH except ValueError: # raises on linux MAX_PATH = 4096 # see comments but I can't find any way to get the value of max filesystem path from python ( os, os.path, sys... ) - is there a standard way or do I need an external lib ? Or there is no analogous as MAX_PATH in linux, at least not a standard among distributions ? Answer try: MAX

silverlight access to file path

≯℡__Kan透↙ 提交于 2020-01-04 04:34:13
问题 I have a Silverlight application and I need a way to find out the physical path for a selected file. Note: I know about security restrictions that obtaining the path is prohibited in client. I have in mind a solution but I am not sure it works: silverlight app is running in a page together with an ActiveX component that is allowed to do restricted operations. The Silverlight app asks the ActiveX component to do the privileged operations and returns back the path. Is that a valid scenario or

How to add a directory to the $PATH variable with macosx leopard

泪湿孤枕 提交于 2020-01-04 04:12:07
问题 I really am unable to add a directory to the $PATH variable. I have tried to add a file text to etc/paths.d/ containing the path i want to add, but the OS refutes to let me add a file to that directory (permission denied). I don't know why, since i login as admin... Please help me, i need to add the adb path for the android sdk on macosx. 回答1: The permissions on /etc/paths.d only allow the root account to write to it, not normal admins. This is actually fairly common in OS X, since many users