Getting Meteor private folder path in Meteor Deploy Environment - deployment

I need to get the path of the file inside the private folder.
On my local machine I was able to get it by using the path "../../../../../", however, when I deployed to meteor server using meteor deploy, it doesn't work anymore. Also I tried to log the current directory using process.cwd() and got the following, which is different from the structure I got on my local machine:
/meteor/containers/3906c248-566e-61b7-4637-6fb724a33c16/bundle/programs/server
The directory logged from my local machine gives:
/Users/machineName/Documents/projectName/.meteor/local/build/programs/server
Note: I am using this path to setup https://www.npmjs.com/package/apn

You can use assets/app/ as the relative path. While this may not make sense on the first look Meteor re-arranges your /private directory to map to assets/app from the /programs/server directory. This is both in development and production.
Basically assume that private/ maps to assets/app/.

Call Assets.absoluteFilePath(assetPath) on one of the assets in the private folder, then chop of the name of the asset file from the string you get back, e.g., assuming you have a file called test.txt in the private folder:
var aFile = 'test.txt';// test.txt is in private folder
var aFilePath = Assets.absoluteFilePath(aFile);
var aFolder = aFilePath.substr(0, aFilePath.length - aFile.length);
console.log(aFolder);
https://docs.meteor.com/api/assets.html#Assets-absoluteFilePath

Related

PyQt5/Python3 reference qss file

I have a PyQt5 (5.15.6) application running in Python 3 and want to reference my qss file as such
qss_file = QtCore.QFile("my_app_qss.qss")
However, I have multiple apps that use the same qss file so depending on where I run the app from I need an absolute import rather than a relative import. I would also like to compile any of those apps with pyinstaller and deploy them to another machine. How can I reference this qss file?
example folder structure
main
| - resources/my_app_qss.qss
| - apps/
|--------project1/app1.py
| -------project2/
|-----------------subfolder/app2.py
The issue is that I did not understand that
qss_file = QtCore.QFile("my_app_qss.qss")
Is not a path to a file. It is referencing a file that gets built by pyrcc4 from the .qrc source

Deploying app, troubles to reffer to datasets. Streamlit

Hello i have one more problem with deploying my app by Streamlit. It works localy but when I want to upload it on git hub it doesnt work..Have no idea whats wrong. It seems that there is problem with path to the file:
"File "/app/streamlit/bobrza.py", line 14, in <module>
bobrza_locations = pd.read_csv(location)"
Here is link to my github repo. Will be very very grateful for help. Thank in advance.
https://github.com/Bordonous/streamlit
The problem is you are hard coding the path of the bobrza1.csv and route.csv to the path on your computer so when running the code on a different environment the path in not legal.
The solution is to make location independent from running environment, for this we will use the following:
__file__ variable - the path to the current python module (the .py file).
os.path.dirname() - a function to get directory name from path.
os.path.abspath() - a function to get a normalized absolutized version of path.
os.path.join() - a function to join one or more path components.
Now you need to change your location and location2 variables in the code to the following:
# get the absolute path to the directory contain the .csv file
dir_name = os.path.abspath(os.path.dirname(__file__))
# join the bobrza1.csv to directory to get file path
location = os.path.join(dir_name, 'bobrza1.csv')
# join the route.csv to directory to get file path
location2 = os.path.join(dir_name, 'route.csv')
Resulting in an independent path of the bobrza1.csv and route.csv.

How can we read a config file stored at a location relative to the Mirth Connect Installation directory?

How can we read a config file stored at a location relative to the Mirth Connect Installation directory?
For example if Mirth is installed in /opt/Mirth-Connect directory and I want to read a file from /opt/Mirth-Connect/conf directory without specifying the fully qualified path name.
We are using multiple instances of Mirth for different environments which are installed on the same machine, So I can't hard code full path in channel configurations.
You can read a config file stored at a location relative to the Mirth Connect Installation directory basically in the same way as you would read any other file, i.e.:
var folder = new java.io.File("./conf");
var listOfFiles = folder.listFiles();
for (var i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
// Do what you need with the file - listOfFiles[i].getName());
}
}
The first line gives you a path relative to the mcserver.exe (in Windows env) installation.
Accordingly, folder = File(".") is a Mirth root folder.

opkg install error - wfopen no such file or directory

I have followed instructions to create an .ipk file, the Packages.gz and host them on a web server as a repo. I have set the opkg.conf in my other VM to point to this repo. The other VM is able to update and list the contents of repositories successfully.
But, when I try to install, I get this message. Can you please describe why I am getting this and what needs to be changed?
Collected errors:
* wfopen: /etc/repo/d1/something.py: No such file or directory
* wfopen: /etc/repo/d1/something-else.py: No such file or directory
While creating the .ipk, I had created a folder named data that had a file structure as /etc/repo/d1/ with the file something.py stored at d1 location. I zipped that folder to data.tar.gz. And, then together with control.tar.gz and 'debian-binary`, I created the .ipk.
I followed instructions from here:
http://bitsum.com/creating_ipk_packages.htm
http://www.jumpnowtek.com/yocto/Managing-a-private-opkg-repository.html
http://www.jumpnowtek.com/yocto/Using-your-build-workstation-as-a-remote-package-repository.html
It is very likely that the directory called /etc/repo/d1/ does not exist on the target system. If you create the folder manually, and try installing again, it probably will not fail. I'm not sure how to force opkg to create the empty directory by itself :/
Update:
You can solve this problem using a preinst script. Just create the missing directories on it, like this:
#!/bin/sh
mkdir -p /etc/repo/d1/
# always return 0 if success
exit 0

How to get specific version of folder from tfs without creating a workspace?

I would like to get the source code of a project at specific time (changeset). So I need do download whole folder. I would like to do it for different times and handling a different workspace is not very convenient.
I know about TFS Get Specific Version into separate folder (with workspace) and Need command to get a file from TFS without a workspace (one file).
Is there some solution for whole folder without creating a new workspace?
Edit
I have found the accepted answer too ambitious. I needed something more simple.
Assumptions:
I can access TFS from Visual Studio on my computer
I want to get the ChangeSetNumber Changeset from the folder
DesiredFolder in TFS project tProj
I run the following batch from a destination folder in Visual Studio Command Prompt
set workspace_name=TemporaryWorkspace%username%
set changeset= ChangeSetNumber
tf workspace -new %workspace_name% -noprompt
tf workfold -map $/tProj . -workspace:%workspace_name%
tf get $/tProj/DesiredFolder -version:C%changeset% -recursive -noprompt
tf workfold -unmap . -workspace:%workspace_name%
tf workspace -delete %workspace_name% -noprompt
It is necessary to confirm remove source control association when starting the downloaded solution.
I use this syntax for temporary workspaces:
tf workspace -new %JOB_NAME%;%user% -noprompt -server:http://%host%:8080/tfs/%project% -login:%user%,%password%
tf workfold -map $/Release/MilestoneX.X . -workspace:%JOB_NAME% -server:http://%host%:8080/tfs/%project% -login:%user%,%password%
tf get . -version:L%TFS_LABEL% -recursive -noprompt -login:%user%,%password%
tf workfold -unmap . -workspace:%JOB_NAME% -login:%user%,%password%
tf workspace -delete %JOB_NAME%;%user% -noprompt -server:http://%host%:8080/tfs/%project% -login:%user%,%password%
I've discovered that you can do this through the HTTP api that TFS exposes.
The "signature" for the URL is as follows:
http(s)://{server}:{port}/tfs/{collectionName}/{teamProjectName}/_api/_versioncontrol/itemContentZipped?version={versionSpec}&path={escapedPathToFolder}
So, if you have a project named "MyProject" in the DefaultCollection, and want to get the content of a folder called "MyFeature":
http://MyTfsServer:8080/tfs/DefaultCollection/MyProject/_api/_versioncontrol/itemContentZipped?version=C1001&path=%24%2FMyProject%2FMyFeature
I think "version" can be any version spec, which is documented in the TFS API documentation. My example is requesting the version as of change set 1001. I was using the .NET API to get a specific version, which is pretty straightforward, but slow because it can only get one file at a time. I'm trying to figure out if this same functionality is exposed through the .NET API because downloading the files this way is much much faster than getting a single file at a time.
I implemented this as an extension method on Microsoft.TeamFoundation.VersionControl.Client.Item. This returns a stream that contains a zip file. I had used this as part of a custom MSBuild task which then saves the contents of this stream to a file location.
public static class TfsExtensions
{
const String ItemContentZippedFormat = "/_api/_versioncontrol/itemContentZipped?version={0}&path={1}&__v=3";
public static Stream DownloadVersion(this Item folder, VersionSpec version)
{
if (folder.ItemType != ItemType.Folder)
throw new ArgumentException("Item must be a folder", "folder");
var vcs = folder.VersionControlServer;
var collectionName = vcs.TeamProjectCollection.CatalogNode.Resource.DisplayName;
var baseUri = folder.VersionControlServer.TeamFoundationServer.Uri;
if (!baseUri.LocalPath.EndsWith(collectionName, StringComparison.OrdinalIgnoreCase))
baseUri = new Uri(baseUri, baseUri.LocalPath + "/" + collectionName);
var apiPath = String.Format(ItemContentZippedFormat, version.DisplayString, WebUtility.UrlEncode(folder.ServerItem));
var downloadUri = new Uri(baseUri, baseUri.LocalPath + apiPath);
var req = WebRequest.Create(downloadUri);
req.Credentials = CredentialCache.DefaultCredentials;
var response = req.GetResponse();
return response.GetResponseStream();
}
}
I think you should create a temporary Workspace to retrieve the content you want, then delete the Workspace and keep the local items.
A Workspace in TFS is a local view of what's on the server, for a given Workspace you choose which folder(s) you want to retrieve locally and where you'll store the folders/files.
It's not like SourceSafe you're not bound to only one workspace, you can have as many as you want on a given computer.
So I suggest you to create a dedicated Workspace for the operation you want to do and get rid of it when you judge it appropriate.
Use the TF.exe workspace command to create/delete a Workspace from the Shell. Then TF.exe get to retrieve the files.
You can use tf view to get a specific file without creating a workspace.
Retrieves a specific version of a file to a temporary folder on your computer and displays it.
tf vc view [/collection:TeamProjectCollectionUrl]
[/console] [/recursive] [/output:localfile]
[/shelveset:shelvesetname[;owner]] [/noprompt] itemspec
[/version:versionspec] [/login:username,[password]]
Versionspec:
Date/Time D"any .Net Framework-supported format"
or any of the date formats of the local machine
Changeset number Cnnnnnn
Label Llabelname
Latest version T
Workspace Wworkspacename;workspaceowner