filepath

How do I set the file path to the current user?

那年仲夏 提交于 2019-12-10 14:55:51
问题 Right now for a directory path, I have: os.chdir(r'C:\users\Ryan\AppData\Local\Google\Chrome\Application') How do I make it so that instead of "Ryan" it uses the username of the person using the script? 回答1: Take a look at expanduser of os.path: os.path.expanduser(path) On Unix and Windows, return the argument with an initial component of ~ or ~user replaced by that user‘s home directory. [..] On Windows, HOME and USERPROFILE will be used if set, otherwise a combination of HOMEPATH and

Desktop Launcher for Python Script Starts Program in Wrong Path

孤者浪人 提交于 2019-12-10 13:16:08
问题 I can not launch a python script from a .desktop launcher created on Linux Mint 17.1 Cinnamon. The problem is that the script will be launched in the wrong path - namely the home folder instead of the directory it is placed in. Thereby it can not find other vital files accompanying it in its folder and hence does not work. To examine that misbehaviour I created a short script to check the folder a python script is executing in: #!/usr/bin/env python import subprocess import time subprocess

Extracting File Extensions from AppleScript Paths

白昼怎懂夜的黑 提交于 2019-12-10 10:59:49
问题 I'm writing an Apple Script that ultimately will mark commercials for all iTunes exports from EyeTV. But I'm running into a simple problem with AppleScript paths, which the EyeTV app returns as recording locations. Here's the context: set recordingID to 370404006 set myid to recordingID as integer tell application "EyeTV" set eyetvr_file to get the location of recording id myid as alias end tell return eyetvr_file alias "Macintosh HD2:Documents:EyeTV Archive:South Park.eyetv:000000001613eaa6

Escaping backslash in Postgresql

天涯浪子 提交于 2019-12-10 04:35:16
问题 I'm trying to write an sql function in Postgresql that will parse a file path. I want to return just the file name. I cannot get past getting an accurate text string in the function. Here is the function: Function: job_page("inputText" text) DECLARE $5 text; BEGIN $5 = quote_literal("inputText"); return $5; END When I run this: select job_page('\\CAD_SVR\CADJOBS\7512-CEDARHURST ELEMENTARY SCHOOL\7512-20.DWG') I get this result: "E'\\CAD_SVRCADJOBSé2-CEDARHURST ELEMENTARY SCHOOLé2-20.DWG'"

Command line passing quotes within quotes

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 02:43:40
问题 I've been searching for a solution to this but couldn't find one. Not sure if its possible. Can I pass into command-line execution that passes a in a bat file which has an input file as its arguments? So from the command-line it'll look like this: C:\run.exe "C:\space folder\run.bat "C:\space folder\input.txt"" The problem is with the folders that has spaces so the quotes are required to be in there. 回答1: Try this: C:\run.exe "C:\space folder\run.bat \"C:\space folder\input.txt\"" And here is

In python, if a module calls upon another module's functions, is it possible for the function to access the first module's filepath?

旧城冷巷雨未停 提交于 2019-12-09 23:52:15
问题 Without passing it as a parameter... Ex. In test1.py: def function(): print (?????) and in test2.py import test1 test1.function() Is it possible to write ????? so running test2.py prints out 'test2.py' or the full filepath? __ file __ would print out 'test1.py'. 回答1: This can be achieved using sys._getframe(): % cat test1.py #!/usr/bin/env python import sys def function(): print 'Called from within:', sys._getframe().f_back.f_code.co_filename test2.py looks much like yours but with the the

Android Download Manager

限于喜欢 提交于 2019-12-09 04:51:52
问题 I think i have a rather simple question. http://www.vogella.com/blog/2011/06/14/android-downloadmanager-example/ I have been following a tutorial in the above url. How do I change the filepath for downloads? Thanks in Advance 回答1: You configure the DownloadManager.Request object with that sort of information. In the tutorial, that Request object is created and used in onClick() . For example: DownloadManager.Request req=new DownloadManager.Request(uri); req.setAllowedNetworkTypes

accessing file on sdcard android

北慕城南 提交于 2019-12-08 18:49:33
I am new to Android development. I am trying to use the following code to email a file on my motorola milestone through gmail. Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("audio/mp3"); sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/king1.mp3"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); sendIntent.putExtra(Intent.EXTRA_TEXT, "this is the email content2"); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/king1.mp3")); startActivity(Intent.createChooser(sendIntent, "Title:")); Running the code sends the email but the attachment

Bash - check for a string in file path

折月煮酒 提交于 2019-12-08 15:22:22
问题 How can I check for a string in a file path in bash? I am trying: if [[$(echo "${filePathVar}" | sed 's#//#:#g#') == *"File.java"* ]] to replace all forward slashes with a colon (:) in the path. It's not working. Bash is seeing the file path string as a file path and throws the error "No such file or directory". The intention is for it to see the file path as a string. Example: filePathVar could be **/myloc/src/File.java in which case the check should return true. Please note that I am

Recursive function for copy of multilevel folder is not working

倾然丶 夕夏残阳落幕 提交于 2019-12-08 13:44:45
问题 Recursive function for copy of multilevel folder is not working. I have a code to copy all the mulitilevel folder to new folder. But in between I feel there is problem of proper path recognition, see the code below.. <?php $source = '/var/www/html/pranav_test'; $destination = '/var/www/html/parth'; copy_recursive_dirs($source, $destination); function copy_recursive_dirs($dirsource, $dirdest) { // recursive function to copy // all subdirectories and contents: if(is_dir($dirsource)) { $dir