Where can I see or create this file ~/.tcms.conf - kiwi-tcms

I am trying to follow this instructon: https://github.com/kiwitcms/junit-plugin/ but I don't know where to set this particular file '~/.tcms.conf:'
Configuration and environment
Minimal config file ~/.tcms.conf:
[tcms]
url = https://tcms.server/xml-rpc/
username = your-username
password = your-password
I don't know where to look for it or create

~/ means your home directory, which in this case is whatever System.getProperty("user.home") returns. On Linux this is usually /home/your-username.
.tcms.conf is the file name inside this directory.

Related

Open file without Filename with lua skript

Good evening,
I am currently working on a programm that takes information from a file into a Database, for testing purposes I used to open Testfiles in the classical way via IO:
function reader (file, delimeter)
local f = io.open(file)
for line in f:lines() do
lines[count] = splitty(line, delimeter)
count = count + 1;
end
end
(this part also containes the first part of a splitter)
But in the actual environment, the database programm imediatly moves the file in another directory with a name change to, for example this:
$30$15$2016$09$26$13$27$24$444Z$.Pal.INV.csv
Now I know the directory but I can't really predict the name, so I wanted to know if there might be a way to open files without knowing their name.
(and delete them after reading them)
I had ideas to use a modified link:
local inputFile = "D:\\Directory\\(*all)"
but it failed.
Other aviable information:
The system is until now only planned on Windows PCs.
The directory will always only contain the one file that is to ready, no other files.
You can use the lfs.dir iterator from LuaFileSystem to iterate through the contents of the directory. A small example:
local lfs = require("lfs")
local path = "D:\\Directory\\" -- Your directory path goes here.
for filename in lfs.dir(path) do
print(filename) -- Work with filename, i will just print it
end
If you keep a record of the files you will be able to know which one is the new one. If it is only one file, then it will be easier, you can just check the extension with a string function. From what i remember the iterator includes .. and .. lfs documentation can be found here.
-- directory name and file name should consist of ASCII-7-bit characters only
local dir = [[C:\Temp\New Folder]]
local file = io.popen('dir /b/s/a-d "'..dir..'" 2>nul:'):read"*a":match"%C+"
if not file then
error"No files in this directory"
end
-- print the file name of first file in the directory
print(file) --> C:\Temp\New Folder\New Text Document.txt

rename a file using C function rename()

I'm using a Mac. I need to rename a file in the /Library/Application Support/AppName/filename.aiff
This is the system library and not /User/username/Library...
I'm using the rename(old name, new name) function. This function doesn't work (even though it doesn't return an error) if I place the file in the /Library/Application Support/AppName directory but it works properly if I place the file, for example, in /User/username/Documents/filename.aiff.
I don't know what the problem is. Any help would be appreciated. Thanks!
You don't own the directory you're trying to move files into:
/Users/Username/... is a user owned directory, so you're allowed to manipulate files there.
/Library is not a user owned directory.
In order to manipulate files in a non-user owned directory you would need elevated permissions. Instead of using /Library you should be using ~/Library, which is the user owned directory. ~/Library is the shorthand name for /Users/Username/Library.
If the rename is working fine in other path means the problem should be related to permission to access file or with the path searched for file.

Can't create a file if a folder exists with the same name

The following code shows the problem I am experiencing:
// Assume working directory is empty.
File foo = new File("asdf");
foo.createNewFile(); // returns true, creates file "asdf" in working directory.
File bar = new File("asdf");
bar.mkdir(); // returns false
When I try to make a directory with the same name as a file that already exists, the "mkdir()" function returns false.
A similar problem occurs when the operations are performed in the opposite order; when the directory is made first, the "createNewFile()" function returns false.
I understand that when the second "File" object is initialised it 'finds' the file created on the previous line therefore "bar.exists() && bar.isFile()" is true.
Please could someone detail how I can create a file with the same name as an existing folder and vice-versa.
Thanks,
Harri
It's impossible, since your operating system (file system) does not permit it. Not a Java issue as such.
You can't create a file and a folder with the same name and in the same folder. The OS would not allow you to do that since the name is the id for that file/folder object.
Assume it was possible and we'd have something like this:
foo (folder)
|- bar (folder)
|- bar (file)
How would you decide which one to open when you get a command "open foo/bar"?
If you can't decide with just that information, then how should the OS decide for you?
It will not be possible as it's your operating system that doesn't allow it. You can always try and if it fails rename the folder (or file):
File bar = new File("asdf");
if(!bar.mkdir()) {
// rename your folder or file
bar.mkdir();
}
// Assume working directory is empty.
File foo = new File("asdf.txt");
foo.createNewFile(); // returns true, creates file "asdf" in working directory.
File bar = new File("asdf");
bar.mkdir(); // returns false
The above code should work for you. Whenever you create file, give some extension so file and directory can be differentiated.

Copy A File In AppleScript

I have the code below to set a variable in Applescript for the path to the iTunes Music Folder:
set username to text returned of (display dialog "RingtoneDude" default answer "Enter your path to your iTunes Ringtones folder here. e.g. /Users/David/Music/iTunes/iTunes Music/Ringtones" buttons {"Confirm", "Cancel"} default button 1)
And then I have the code to call the variable username to copy a file
tell application "Finder"
copy file theCopy to username
end tell
but the file theCopy which is on the desktop (theCopy is a variable) does not move to the folder.
Please help.
I believe you've misunderstood the copy command. The copy command is used for transferring the contents of one variable into another variable. What you need to use is the duplicate command, which is used for copying files to a specified location. Its syntax is as follows:
duplicate [alias] to [alias]
[replacing boolean] --If true, replaces files in the destination with the same name
Having said that, your new code, in conjunction with Uriah Carpenter's answer, should look something like this:
set myRingtoneFolder to choose folder with prompt "Select your iTunes Ringtone folder:"
tell application "Finder" to duplicate theCopy to myRingtoneFolder
I would suggest you use choose folder which returns an alias.
To make some text into an alias object use set myAliasPath to myTextPath as alias.
For more detailed information see Aliases and Files in the AppleScript documentation.

Access denied to resource file from java servlet

I am trying to access a resource file from a servlet but getting HTTP Error 500 - access denied:
File file = new File("//warChildFolder//myFile.txt");
InputStream is = new FileInputStream(file); // <--error on this line
I am on google-app-engine.
Any help appreciated!
Google App Engine docs talk about "white listing" a file. Is that in play here?
I also wonder about this:
File file = new File("//warChildFolder//myFile.txt");
Doesn't the leading slash make this an absolute path?
I'd try it like this:
File file = new File("WEB-INF/warChildFolder/myFile.txt");
Make the path relative to the WAR root and be explicit about WEB-INF.
I'm not sure about Google App Engine but in my experience the only solution that works across containers and platforms is to use ServletContext.getRealPath().
new File(servletContext.getRealPath("/WEB-INF/warChildFolder/myFile.txt"));
The spec says: use forward slashes and a leading slash. This gives you platform independence and you're not relying on the process' current directory.
Does it work if you use single path separators?
(updated to use relative paths):
File file = new File("warChildFolder/myFile.txt");
You need to escape the "\" character in Strings, so use "\", but a single "/" is all that is needed.
Update: It may be that the path being processed is not the same as you expect, you can try logging the absolute path of the file (with file.getAbsolutePath()) to check this.
Another thing to check is that the process has read permissions on the folder/file. If you're not on Windows this can be a problem.

Resources