temporary-directory

Python: Why am I receiving an AttributeError: __enter__

独自空忆成欢 提交于 2021-02-10 05:14:32
问题 I am not reassigning the open keyword yet still receive this error. Any suggestions or direction to fix my error? with tempfile.mkdtemp() as test_dir: print(test_dir) AttributeError: __enter__ I am also new to python and I am having a hard time understanding these concepts. 回答1: You're using mkdtemp incorrectly. mkdtemp returns the path name as str, not a context manager. If you want a context manager for managing a temporary directory, you need to use TemporaryDirectory, which is available

“folder has not yet been created” error when using JUnit temporary folder in testclass

回眸只為那壹抹淺笑 提交于 2021-02-08 13:11:18
问题 I get the error "the temporary folder has not yet been created", which comes from an IllegalStateException thrown by the TemporaryFolder.getRoot() method. It looks like it's not initialized, but my research showed me that this is usually the case when the temp folder is initialized in setUp()-method. But using it with @Rule like I did should work in my opinion. Any ideas? The test class public class FileReaderTest extends TestCase { @Rule public TemporaryFolder folder = new TemporaryFolder();

“folder has not yet been created” error when using JUnit temporary folder in testclass

只愿长相守 提交于 2021-02-08 13:04:25
问题 I get the error "the temporary folder has not yet been created", which comes from an IllegalStateException thrown by the TemporaryFolder.getRoot() method. It looks like it's not initialized, but my research showed me that this is usually the case when the temp folder is initialized in setUp()-method. But using it with @Rule like I did should work in my opinion. Any ideas? The test class public class FileReaderTest extends TestCase { @Rule public TemporaryFolder folder = new TemporaryFolder();

Creating a unique temporary directory from pure C in windows

江枫思渺然 提交于 2020-06-24 11:32:47
问题 I'd like to create a unique temporary directory in Windows from some C code (not C++ or C#). I want to do this so that I can put some temp files in the directory, and then delete them all easily when I'm done (by removing the directory recursively). I'm essentially looking for an equivalent of the linux mkdtemp function. There is a C# answer here, and responses on this question suggest using Boost. But since I'm using C, those solutions don't work for me. The best I've been able to come up

Cross-platform way of getting temp directory in Python

自作多情 提交于 2020-01-22 04:04:30
问题 Is there a cross-platform way of getting the path to the temp directory in Python 2.6? For example, under Linux that would be /tmp , while under XP C:\Documents and settings\[user]\Application settings\Temp . 回答1: That would be the tempfile module. It has functions to get the temporary directory, and also has some shortcuts to create temporary files and directories in it, either named or unnamed. Example: import tempfile print tempfile.gettempdir() # prints the current temporary directory f =

How to create a temporary directory?

大兔子大兔子 提交于 2019-12-31 07:52:17
问题 I use to create a tempfile , delete it and recreate it as a directory: tmpnam=`tempfile` rm -f $tmpnam mkdir "$tmpnam" The problem is, another process may get a same name X , if it accidently executes tempfile after one process rm -f X and just before mkdir X . 回答1: Use mktemp -d. It creates a temporary directory with a random name and makes sure that file doesn't already exist. You need to remember to delete the directory after using it though. 回答2: For a more robust solution i use something

Possible to move the tmp directory of Eclipse?

别等时光非礼了梦想. 提交于 2019-12-21 12:37:11
问题 I'm trying to speed up Eclipse by having my projects on a RAM disk (stuck with a slow laptop and a heavy kind of eclipse project at the moment). Worked great for loading the project and such, but when I'm building it seems to read and write a lot to a directory in %APPDATA% (seems to have a generated name from the name of the project). This makes it actually go slower than usual... So... is there a way I can move the tmp directory of eclipse? Preferably without moving the tmp directory of

How to create a temporary directory in C++?

坚强是说给别人听的谎言 提交于 2019-12-17 07:37:46
问题 I'm writing a function in C++ which creates a temporary directory. Such function should be as most portable as possible, e.g. it should work under linux, mac and win32 environments. How do I achieve that? 回答1: Version 3 of Boost Filesystem Library provides function unique_path() for generating a path name suitable for creating a temporary file or directory. using namespace boost::filesystem; path ph = unique_path(); create_directories(ph); 回答2: Check the mkdtemp function here. 回答3: C++17 std:

Create a temporary folder to keep the files in structure and make it downloadable by compressing the folder

不想你离开。 提交于 2019-12-13 06:37:00
问题 In my project, I have some files related to items on Server as shown below: Item-1 => file1.txt, file2.pdf and file3.doc Item-2 => file4.pdf, file5.ppt Item-3 => file6.txt, file7.docx and file8.ppt .... I can get the above items by $this->getAllItems() and then loop through each item. I am trying to compress all these files in a structured way. So, that the user can understand files belong to which items. What I am trying to do is keep the files related to their respected items in a folder

Composer install: error on temporary file

柔情痞子 提交于 2019-12-12 02:37:38
问题 I have a problem with windows 10 and composer (last version). When I want to execute command "composer install" in my project, a symphony error is thrown: [Symfony\Component\Process\Exception\RuntimeException] A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable My TEMP variable is "%USERPROFILE%\AppData\Local\Temp". The folder exists and permissions are good. Can anyone help me to find the problem please? Thank you. 回答1: