working-directory

python: Change the scripts working directory to the script's own directory

坚强是说给别人听的谎言 提交于 2020-01-18 05:16:04
问题 I run a python shell from crontab every minute: * * * * * /home/udi/foo/bar.py /home/udi/foo has some necessary subdirectories, like /home/udi/foo/log and /home/udi/foo/config , which /home/udi/foo/bar.py refers to. The problem is that crontab runs the script from a different working directory, so trying to open ./log/bar.log fails. Is there a nice way to tell the script to change the working directory to the script's own directory? I would fancy a solution that would work for any script

PyDev console working directory

谁说我不能喝 提交于 2020-01-13 18:04:58
问题 When I open a PyDev console, the current working directory is my Eclipse folder. How can I configure the console to use the project folder as the current working directory? Can this be set workspace-wide? This question is related, but unhelpful as the directory is hard coded. So far, I've discovered that the Eclipse run configuration variable ${project_loc:/selected project name} cannot be used with Python's os.chdir() . 回答1: If you go to Windows -> Preferences -> PyDev -> Interpreter, you

Can you set the current running directory from the java command line?

北城余情 提交于 2020-01-13 07:32:17
问题 I am running a Java application from the command line. Can I specify a command line argument to set the current running directory to something other than where the application is actually going to run? 回答1: There is a JVM argument -Duser.dir which can be used to set working directory for JVM. 回答2: If it all possible I would rather use a script to run the java application and set the directory in the script: #!/bin/sh cd <your dir> java <some arguments> The JNI-solution may affect all kinds of

How do I make JFileChooser open in the current directory the user is in?

拜拜、爱过 提交于 2020-01-05 10:26:42
问题 I do not want to specify a directory. I just want it to automatically "know" and open in the directory the user is working in. How do I do this? 回答1: This examples defaults to the user.dir on first showing. It then retains the instance of the chooser to automatically track the last load or save location, as suggested by MadProgrammer. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.io.*; public class ChooserInCurrentDir { //

How can I get the working directory of a project from an Annotation Processor in Java

倖福魔咒の 提交于 2020-01-04 04:20:26
问题 I am writing an annotation processor in Java and in this annotation processor I want to be able to find a file in the Project hierarchy of the project on which I am using this annotation processor. Through the annotation I can pass in the path of the file I am searching for relative to the project root but i cannot retrieve the project's working directory. Let's say that the processor is MyCustomProcessor and I am using it on the project MyProject. I want to be able to access(read) a file (a

Programatically checking files into TFS getting more than expected

你。 提交于 2020-01-03 18:49:08
问题 So I have a .NET app which goes thru and generates a series of files, outputs them to a local directory and then determines if it needs to update an existing file or add a new file into a TFS (Team Foundation Server) project. I have a single workspace on my local machine and there are 10 different working folders that are other coding projects I have worked on from this particular machine. My problem happens when I go to check if the file already exists in the TFS project and an update is

How to change the default working directory in python

若如初见. 提交于 2020-01-03 07:01:09
问题 I have a quick question about the default working directly on python. I am currently using the python 2.7. In this case the default working directly is the C:/Python27 . I want to change this permanently to another directory. Even if we write down following on shell, the default working directory will go back to the original C:/Python27 automatically. import os os.chdir('a path') Does any one know how to set up default directory permanently to "the path" which keeps the directory after the

Can I import a patch without touching the working directory?

末鹿安然 提交于 2020-01-02 02:05:33
问题 Normally, Mercurial will abort if I have a dirty working copy when I try to import a patch: $ hg import x.patch abort: outstanding uncommitted changes Is it possible to import it anyway? 回答1: With Mercurial 1.9, you can use hg import --bypass to apply a patch without touching the working copy. The patch will be applied on the working copy parent revision by default. Use the --exact flag to apply the patch onto the changeset mentioned in the patch header instead. 回答2: If you are using

How to set the current working directory in Dart? [duplicate]

六月ゝ 毕业季﹏ 提交于 2019-12-31 00:30:36
问题 This question already has an answer here : How do I find the current directory, in Dart? (1 answer) Closed 2 years ago . In a dart console application, how do I set the current working directory? 回答1: import 'dart:io'; ... Directory.current = new Directory('your/path/here'); or just Directory.current = 'your/path/here'; See also https://api.dartlang.org/133671/dart-io/Directory/current.html 来源: https://stackoverflow.com/questions/33020117/how-to-set-the-current-working-directory-in-dart

Command for “Set working directory to source file location”

浪子不回头ぞ 提交于 2019-12-30 17:28:07
问题 RStudio has a useful feature: Session -> Set Working Directory -> To Source File Location Is there a way to do this without using the drop down menus? UPDATE: maybe a better way of asking is: is there a command to return the file path of the current r script? I also found this thread, but the solutions didn't work for me. Not even Hadley's! Rscript: Determine path of the executing script 回答1: You can use : source("script.R", chdir = TRUE) and change "script.R" by the name of the file you're