path

Getting short path in python

余生长醉 提交于 2020-01-04 03:19:05
问题 How do I obtain the short path of a file in Windows using python ? I am using the following code , #!/usr/bin/python import os import sys fileList = [] rootdir = sys.argv[1] for root, subFolders, files in os.walk(rootdir): for file in files: fileList.append(os.path.join(root,file)) for File in fileList: print File 回答1: I guess you are looking for this: http://docs.activestate.com/activepython/2.5/pywin32/win32api__GetShortPathName_meth.html Although you will need the win32api module for this.

How to know the path the script the python run?

萝らか妹 提交于 2020-01-04 01:51:06
问题 sys.arg[0] gives me the python script. For example 'python hello.py' returns hello.py for sys.arg[0]. But I need to know where the hello.py is located in full path. How can I do that with python? 回答1: import sys print(sys.path[0]) From the docs: As initialized upon program startup, the first item of this list, sys.path[0], is the directory containing the script that was used to invoke the Python interpreter. 回答2: os.path.abspath(sys.argv[0]) 回答3: You can use __file__ , a variable that

PostgreSQL command psql not found, trouble adding to $PATH

早过忘川 提交于 2020-01-04 01:50:16
问题 I am trying to add PostgreSQL to my $PATH variable. I tried this to see where psql is whereis psql To which I got a null response. I do have the PostgreSQL.app installed so I clicked on "Open psql" from the GUI and it prompted the Terminal to open and display: /Applications/Postgres.app/Contents/MacOS/bin/psql; exit; So I tried to add the above to the $PATH variable in my ~/.bash_profile (which may have its own problems since I don't know if you can add paths with .app extensions to the $PATH

Using relative url for window.location in child iframe

假如想象 提交于 2020-01-03 19:34:13
问题 I'm having trouble with an iframe-related issue. I have a document (parent) with an iframe (child). If the parent document calls a function in the child which changes the childs url using window.location to a relative url, that url becomes relative to the parent document. Let me illustrate. Parent document: /test/parent.html Child document: /projects/child.html Child code: function moveOn(){ window.location.href = "newPage.html"; } Parent code: childDocument.contentWindow.moveOn(); Result:

How to get CMake to use the default compiler on system PATH?

拜拜、爱过 提交于 2020-01-03 16:46:20
问题 There is the same question and the answer. The problem is that the answer seems to be wrong (actually is not the answer to the asked question). Can I re-ask the question? The problem: $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games $ whereis gcc cc: /usr/bin/gcc /usr/lib/gcc /usr/local/bin/gcc /usr/libexec/gcc $ which gcc /usr/local/bin/gcc $ /usr/bin/gcc -v gcc version 4.1.2 $ /usr/local/bin/gcc -v gcc version 4.8.4 $ gcc -v gcc version 4

How to convert ~/. path to absolute path

笑着哭i 提交于 2020-01-03 15:19:08
问题 I have the following file: ~/.config.txt which is located in /root/.config . In order to avoid hardcoded paths in my Python file, how can I always replace (and correctly refer) to a ~/ path as <home> in Python? This way I could replace ~/.config.txt by /root/.config if /root/ was my home directory? 回答1: You can use os.path.expanduser to convert ~ into your home directory: >>> import os >>> os.path.expanduser('~/.config.txt') '/root/.config.txt' >>> This works on both *nix and Windows systems.

How to form a PHP tree menu? [closed]

拟墨画扇 提交于 2020-01-03 05:18:10
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have some paths stored in my db as: They are unsorted and can be any length. --------Paths-------- C:/devices/data1 C:/devices/data1/application2 C:/devices/data1/application1 C:/devices/data2/application3 C:

Java Jersey - Same method with different parameter on same @path?

不羁岁月 提交于 2020-01-03 02:31:10
问题 I'm newbie on creating web services with Jersey and I'm facing with this problem: @GET @Path("/logoutUser") @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8") public Response logoutUser(@QueryParam("userName") String userName) { if (userName.equalsIgnoreCase("jmart") || userName.equalsIgnoreCase("jromero")) { return Response.status(Response.Status.OK).entity("Logout realizado").type(MediaType.APPLICATION_JSON).build(); }else { throw new CustomNotFoundException("No se ha podido realizar

CMD enviroment variables not expanded in PATH variable

 ̄綄美尐妖づ 提交于 2020-01-03 02:12:38
问题 I've some enviroment variables set in my sistem preferences (Windows 8.1). If i start cmd.exe and execute this commands: C:\Users\Carlo>echo %GRAILS_HOME% D:\Grails C:\Users\Carlo>echo %GRADLE_HOME% D:\Gradle C:\Users\Carlo>echo %GROOVY_HOME% D:\Groovy C:\Users\Carlo>echo %PATH% C:\ProgramData\Oracle\Java\javapath;c:\Program Files (x86)\Intel\iCLSClient\; c:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows; C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\; C

Displaying local htm file in iframe?

橙三吉。 提交于 2020-01-02 09:54:17
问题 I am saving some emails on my local machine using MailBee.NET Objects in htm format. A separate folder is created for each email using email messageID on server for example D:\Emails\GmailId1380ec660e0e656a\doc.htm is an email downloaded from gmail. I am saving also the above mentioned path in database so I can use it later. Now I am trying to display this htm file in an iframe but it is not working. A user clicks on email which takes him to the read_email page on which I am trying to assign