I,m new to applescript and trying to do the following.
I have an Apple script, which will be called by java program and does a work.
Now, I want to make sure that only one applescript runs at a given time. Means, if two class in java calls the applescript, I need to make sure one waits until the other applescript done with the work.
How do I do it?
Thanks in advance.
I don't think you can share global variables between applescripts.
So one way to achieve your goal would be to create a global UNIX variable and a Singleton class around it...
Related
I want to make a command line to make all modules i need in every single project in laravel..I have searched a lot but i can't get a direct answer.
If you want a shortcut to generate all the needed files for routes/controllers/models/views, I would suggest this amazing package to use. It makes your life easier and it saves some time for the routine steps you have to do when you need a new module.
Laravel-Modules
First off, I am a serious newbie so please be gentle.
I am going to try and build a small browser based form (just pure HTML hopefully) to create standardized project numbers. This will require two variables, one for the facility and one for the project title.
I found a PowerShell script that will create the folders I need, but I do not understand how to make the form send things to it. Can anyone point me in the right direction?
I have written a simple shell script to accomplish a common task, and I want to be able to run it whenever a button is clicked. I've used gnome-shell-extension-tool to create the Hello World example already, but now I need to know how to simply have it run an arbitrary command when clicked. There is no input or output to be concerned with; it just needs to run.
After some more creative googling, I've found the solution:
const Util = imports.misc.util;
Util.spawn(['/path/to/program', 'arg1', 'arg2'])
const GLib = imports.gi.GLib;
let stuff = GLib.spawn_command_line_sync("cat hello.txt")[1].toString();
For those looking to read the output of the command, use this.
The default working directory for Gnome shell extensions is the user's home directory.
Just thought I'd mention these things, because it took me a while to figure them out.
I'm trying to make Core Data objects inherit from my own custom class rather than NSManagedObject. I started using Mogenerator and noticed that it has a --base-class arugument which does exactly what I want.
The problem is that by default it doesn't use this parameter, and so every time I save my data model file, it sets the inherited class to NSManagedObject. Is there any way to add this additional parameter to the script so that it works as I want it to every time I save the .xcdatamodel file?
If not, is there any other way I can easily run this command from Xcode? I was thinking about creating it as a User Script. The problem is that I don't want it hardcoded to this project's files. This is an example of the command line I need to run:
mogenerator -m MyProject.xcdatamodeld/MyProject.xcdatamodel -O Classes --base-class MyManagedObject
Ideally, it should find the .xcdatamodel file of the current project. As I have no experience in mac development, I would appreciate it if you could point me in the right direction and tell me which commands will be the most useful to me if do indeed make this script myself.
From the Mogen readme
Xmo'd: model comments that start with
-- are passed as args to mogenerator. This allows accessing command-line
options such as --base-class. (David
LeBer)
In Xcode, get info on the actual .xcdatamodel file and in the Comments tab enter xmod and then the args. That should customize Mogen as you wish.
I suspect for this question, filing a bug on github will get Wolf's attention. I am not sure he goes to this site.
I posted this basic question before, but didn't get an answer I could work with.
I've been writing applications on my Mac, and have been physically making them into .app bundles
(i.e., making the directories and plist files by hand). But when I open a file in the application by right clicking on the file in finder and specifying my app, how do I then reference that file?
I mostly use python, but I'm looking for a way that is fairly universal.
My first guess was as an argument, as were the answers to my previous post, but that is not the case.
Py:
>>> print(sys.argv[1:])
'-psn_0_#######'
Where is the file reference?
Thanks in advance,
The file is passed by the Apple Event, see this Apple document. You need to receive that from inside your Python script. If it's a PyObjC script, there should be a standard way to translate what's explained in that Apple document in Objective-C to Python.
If your script is not a GUI app, but if you just want to pass a file to a Python script by clicking it, the easiest way would be to use Automator. There's an action called "Run Shell Script", to which you can specify the interpreter and the code. You can choose whether you receive the file names via stdin or the arguments. Automator packages the script into the app for you.
This is not an answer but it wouldn't fit in the comments. To respond to #Sacrilicious and to give everyone else insight on this:
#Sacrilicious You're talking about something different. Download this sample application, it's a python script wrapped as an "App". Look inside and find a 4-line python script: myscript.app/Contents/MacOS/myscript - which will print the arguments using
file = open("/tmp/test.txt", "w")
file.writelines(sys.argv[1:])
Stick it in your Applications folder. Then right click some file and choose "Open With" and select this myscript.app.
Now take a look at /tmp/text.txt and you'll see that something like -psn_0_####### is there and not the name of the file you had selected "open with". This is because the file is passed using Apple Events and not a filename as an argument.
So this question is asking how can you access the filename of the thing that was passed in the python script wrapped in an OS X .app application wrapper, and if someone can let me know that they'll get the Bounty :)
Are we referring to the file where per-user binding of file types/extensions are set to point to certain applications?
~/Library/Preferences/com.apple.LaunchServices.plist
The framework is launchservices, which had received a good amount of scrutiny due to 'murkiness' early in 10.6, and (like all property list files) can be altered via the bridges to ObjectiveC made for Python and Ruby. Here's a link with Python code examples for how to associate a given file type with an app.
I've never heard of it being done without a Cocoa / Carbon wrapper.
I described how to link certain filetypes to py2app-bundled Python applications at https://moosystems.com/articles/8-double-click-on-files-in-finder-to-open-them-in-your-python-and-tk-application.html