How can I write the code to open an app without entering a specific username - python-3.9

How can I write os.getlogin to open an app like zoom using the code given below
subprocess.Popen('C:\\Users\\srini\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe')
I first tried this
subprocess.Popen('C:\\Users\\', os.getlogin, '\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe')
The code is running but the app is not being opened by python
I had imported subprocess and os
I tried this code too just to see that if it works
os.path.join(os.path.expandvars("%userprofile%"),"AppData", "Roaming", "Zoom", "bin", "Zoom.exe")
But it's still the same
Is there any way to open and app without writing the path or a way that makes this task easier?
👆👆👆👆👆👆👆
I want to write this code for almost all apps on my laptop so are there any codes that can help me in the way mentioned in the above question
BTW I am a beginner and I know few codes, so plz help me understand this.

I think you are on the right track using os.getlogin(). You can also use getlogin.getuser() or os.getenv('username').
Look at this method to create your path.
path = os.path.join("c:\\Users",os.getlogin(), "AppData", "Roaming", "Zoom", "bin", "Zoom.exe")
subprocess.Popen(path)
or in one line with f-strings
subprocess.Popen(f"c:\\Users\\{os.getlogin()}\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe")

Related

Cordova file plugin can't access the application directory on windows 8

Please help, I can't seem to get an answer for this anywhere.
If I use the Cordova file plugin to try and access the application directory on Windows 8, it always fails! Here is the basic code I am using:
window.resolveLocalFileSystemURL(cordova.file.dataDirectory + 'www/assets/images/image.png', gotFile, fail);
I have been using the same basic code on the Android and iOS versions of the app for some time now with no problem so I don't understand why the Windows 8 version doesn't like it.
Through console logs I can see that the link generated is in fact correct and it's actually exactly the same as one used to append the same image to the page (which works fine):
<img src="ms-appx:///www/assets/images/image.png">.
Can anyone please tell me why I can't use cordova.file.applicationDirectory with Windows? I know that folder is read only, I am just trying to read from it.
Note: I can use window.resolveLocalFileSystemURL with the cordova.file.applicationDirectory no problem at all, it works as expected. Its only the cordova.file.dataDirectory that always fails for me. The closest answer I could find was some people having trouble with the image paths of images saved from the camera plugin but that seems to have been a bug that was fixed by Cordova. If this is not a bug also then I'm assuming there is something really simple I can do to make the resolveLocalFileSystemURL work?
Thanks.
I found a solution to my problem by using 'windows.storage.storagefile', I had success with the following code:
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(new Windows.Foundation.Uri('ms-appx:///www/test.html')).done(win, fail);
More info can be found here: msdn.microsoft.com/library/windows/apps/… I hope this helps some other people struggling with Windows 8 as I spent quite a time scratching my head about it and trying lots of different ways.
Cheers,
Stuart

How to configure this .pl file

I'm trying to import or install MusicBrainz' database and I'm following this instruction.
My OS is Windows so I'm following Windows instruction. I've done up to number 4, but when I opened to configure settings.pl file(link) I couldn't understand what that file wants me to configure.
I think the lines looking like this
$g_schema_url = "$schema_base/admin/sql/CreateTables.sql";
is the part I need to change for the file to work, but I don't think I understand these lines.
I googled and found out that .pl files are the files written in a language called Perl. But I didn't download or install the language because the instruction didn't require me to. Should I? I really am a beginner so even I sound stupid I hope you can understand.
I'm working on Oracle 11.
I've never used MBZDB before, but I looked through the settings.pl and I don't believe for a standard install you should need to change anything. You should be able to move on to step 6.
Edit: I was incorrect: I failed to notice you are using an Oracle database. As a commenter posted, it looks like it will work best with MySQL. If you install that, though, you should be good to go.

IBM Worklight - Shell Component

When I have created a shell component, inside the shell component common folder there is folder called preview. I need to know what is the use of this folder. I am trying to understand about it using the following point specified in IBM modules.
preview: can be used to implement native functionality stubs for simulation in the Worklight Console preview instead of receiving exceptions
Still i am not having any clear idea about this. Can anyone give a clear idea about this.
Thanks in advance!
I believe that the main idea of the preview folder for shell component is to simulate its native behaviour, let's say for example you want to you the Google Maps API on a given area.
For the one developing the shell they do not have the final App, to test its behaviour. So, they can create some simulation such as a picture for a Map or a Picture of a Android TOAST, to allow them to work in the shell it self.

Generating c# file from .proto file using protogen on pre build event

We've been using protobuf for a while at work and I decided to write a little console app for a client which would allow them to do some testing on site.
I started a new c# console app and downloaded google.protocolbuffers and protobuf-net from nuget.
What I'm trying to achieve is to turn my "messages.proto" file into "messages.cs"
I've tried to get the protobuf to build the messages file on a prebuild event but with no success, it seems the command arguments have changed since our first implementation. I followed the example here
http://code.google.com/p/protobuf-csharp-port/wiki/ProtoGen
And added the following pre build event
"$(projectdir)packages\Google.ProtocolBuffers.2.4.1.473\tools\protogen.exe" --proto_path=./protos protos/messages.proto --include_imports -output_directory=./
However I get the following error
Input file protos/messages.proto doesn't exist.
I've tried all sorts of combinations but nothing seems to work. Am I approaching this all wrong or is there a gotcha here? Any help much appreciated!
Have you tried using the absolute paths? I vaguely recall having a similar issue myself that turned out to be an issue with it not resolving relative paths correctly.

Saving PDF files with Chickenfoot

I'm writing a web-crawler using Chickenfoot and need to save PDF files. I can either click the link on the page or grab the PDF's URL and use
go("http://www.whatever.com/file.pdf")
and I get the firefox "Opening file.pdf" dialog box, but can't click the "OK" button to actually save the file.
I've tried using other means to download the files (wget, python's urllib2, twill), but the PDF files are gated so none of those will work.
Any help is appreciated.
This example of how to save a target in the Mozilla developer documents looks like it should do exactly what you want. I've tested a Chickenfoot example that is very similar that gets the temp environment variable, and that worked well for me in Chickenfoot.
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIWebBrowserPersist#Example
You might have to play with the application associations in Tools, Options, Applications to make sure the action is set to Save File, but those settings might not apply to these functions.
End Answer, begin related grumblings...
I sure wish someone would fix the many bugs in Chickenfoot, and write a nice Cookbook programming guide. I've been using it for years, and there are still many basic things I've not been able to figure out how to do. I finally broke down and subscribed to the mailing list, as the archives have some decent script examples. It takes a lot of searching through the pdf references, blogs, etc. as the web API reference is very sparse.
I love how simple Chickenfoot can make automating some tasks, but it takes me days of searching javascript, DOM, and Firefox documents to find ways to do some of the things it can't, since I'm not really a web programmer. The goal of Chickenfoot seems to be that I shouldn't have to be, but unfortunately few are refining the proof of concept, as MIT has dropped the project.
I tried to do this several ways using only Chickenfoot commands and confirmed they don't work with the latest Firefox 3 and Chickenfoot 1.0.7.
I hope this helps! Good luck. Sorry I only ran across your question yesterday, but found it too interesting to leave alone.
You won't be able to click on Firefox dialogs for the sake of security.
The best way to download the content of a URL is to read then write the content of the URL.
// Chickenfoot 1.0.7 Javascript Code to download the content of a url.
include( "fileio.js" ); // enables the write function.
var url = "http://google.com",
saveFileTo = "c://chickenfoot-google.com";
write( saveFileTo, read( url ) );
You might find it helpful to use jquery with chickenfoot.
http://groups.csail.mit.edu/uid/chickenfoot/scripts/index.php?title=Using_jQuery,_jQuery_UI_and_similar_libraries
This has worked for me to save Excel files from NCES portal.
http://muaz-khan.blogspot.com/2012/10/save-files-on-disk-using-javascript-or.html
I was using Firefox 3.0 and the "old syntax" version of the code. I also stripped code intended for IE and "(window.URL || window.webkitURL).revokeObjectURL(save.href);" which generated an error.

Resources