Adding read/write permission to access external HD under Catalina - python

I'm working on MAC application contains a command line tool.
The GUI (electron) using sudo prompt to run the command line tool written in Python.
Under Catalina, the app all needed permission to w/r for the protected directories like Desktop with no issue.
Needed permission request were added to plist and it is signed with list of entitlements.
All works well except accessing external hard drive. Any try to create folder or modifying its properties using chmod command for example return with permission denied.
Just for note, calling same command from terminal ends well with no issue
Any ideas how I can go over it?
How App can request Full disk access?

Related

Problems installing Cloud SQL Proxy on Windows 64-bit

I'm trying to install Cloud SQL Proxy for Google Cloud Platform on my Windows 10 64 bit OS, so I can use Python scripts to dump data into SQL. I'm following this guide to get it set up.
I created a project and a Google Cloud SQL instance from the Console without any issues, and it shows up in the SDK shell without any problems. After downloading the proxy installer and installing it, a dialog window opens up and then closes before I can read it.
When I go to the Google Cloud SDK shell and try to start the Cloud SQL Proxy with: cloud_sql_proxy.exe -instances="[MyInstanceConnectionName]"=tcp:3306
No matter how many times I try, it throws the error "Cloud Sql Proxy is not recognized as an internal or external command, operable program or batch file." I already tried re-downloading and re-executing the file but it still won't work.
I have Python 3.6 with Anaconda and Google Cloud SDK shell installed on Windows 10 64-bit.
When you download the cloud_sql_proxy file make sure to rename it as per instructions in the how to guide. Also make sure you save it in the root directory of where you will run it from. E.g. If you are running the command from C:/users/desktop>.\cloud_sql_proxy.exe -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:3306 then the cloud_Sql_proxy file must be located in the root C drive.
Open PowerShell or whatever terminal you use and navigate to the folder you saved cloud_sql_proxy.exe then add .\ like so:
.\cloud_sql_proxy.exe -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:3306
I had the same problem, and i solved it by adding .\ before
so it would be like this
.\cloud_sql_proxy.exe -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:3306
and I used PowerShell instead of normal cmd
Go to folder where you save proxy exe file and run following command
.\{cloud_sql_proxy file name}.exe -instances={projectID}:{zone}:{sql instance name}:{database}=tcp:{port} -credential_file={service account file path}
For instance related detail go to the instance look for "Instance connection name"
Your command is missing .\ before cloud_sql_proxy.exe -instances="[MyInstanceConnectionName]"=tcp:3306

Python application permission denied

My Python program uses the terminal(system) command to perform the task on the file and script. I am going to convert this Python program into Mac OS application and Linux application using pyinstaller. I am going to pass the application installer file to my friends. However, I have following questions.
If script or file doesn't have proper permission which my program is trying to access, will Python get an error?
Running some script or opening file will require the permission of root. So is there a possible option that will prompt the user for root(admin) password or run my application with root privilege?
Thanks
Try chmod 777 filname.py, this will give the file all rights for execution and editing. There are also other modes for chmod like 755, which will also work for your case.

How can I execute Adobe After Effects via an EC2 Windows Server 2012 Instance?

I have an After Effects script that renders a custom video based on strings passed to it via a webpage form and some python code. It runs just fine when I execute the python code from a remote desktop connection using the administrator account. However when I try to execute it via the web page I can see that After Effects blinks on for a second in the Task Manager but it fails to output any files like it does when run as the administrator.
I'm assuming this is due to some crazy permissions issues with IIS. I've added the after effects executable directory as a virtual directory in IIS. I've also allowed the after effects executable file in the CGI restrictions. I've also set the executables folder to allow read, write, and execute permissions for the IIS-User account.
Any ideas?

ffmpeg permission denied though the user has permission

I have installed ffmpeg in my server running ubuntu 14. my flask app project root is at /var/www/project/
i am able to upload files and my python scripts are able to write new files, but when i run ffmpeg in my script it gives permission denied.
Also running the below line in terminal
ffmpeg -i path/to/inputfile /path/to/outputfile & ps aux | grep ffmpeg
gives the user running the process is "ubuntu" which has write access to the project folder and its subfolders. As i told you other python script run by user "ubuntu" is able to create file.
permission denied error happens in both cases(python script and directly in terminal)
update:
also looking at the confusion with the permissions, is there a way i can run the app from /home/ubuntu/project instead of /var/www/project. i am using mod_wsgi with apache for my flask-app.
right now i have added sudo and it is working fine, though i am not sure running ffmpeg as sudo would cause any security issue. Anyone please clarify on this.
cmd='sudo ffmpeg -i '+f_name+' -acodec '+job['audio_ff']+' -b:a '+job['audio_bps']+'k - b:v '+job['video_bps']+'k -s '+job['res_width']+'x'+job['res_height']+' '+new_file
p=subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE)
The files which are created by your app resides in the var/www/project and these need administrative privilege, if you want to read/access them. Without using sudo you cannot access the administrative protected files.
You can change the rights of the files created by your app to be accessed by ffmpeg without sudo or change the ownership to your username with chown..
Have you checked if your ffmpeg executables have permissions for all the users?

Subprocess change folder permission on Picloud (an AMAZON EC2 server)?

In Ubuntu, I use subprocess.Popen to call an executable file, which will save some output files on the hard drive of server (Picloud). The code has been tested successfully on a Local Ubuntu machine. However, it does not work on the server. My approach is listed below:
#create a new folder.
#The permission is drwxrwx--- both locally and on the server end
os.makedirs(folder)
#copy the executable file to this folder.
#The permission is drwxrwx--- both locally and on the server end after copy
shutil.copy("a.exe", folder)
#call this exe file.
#The permission is drwxrwx--- locally but changed to drwxr-x--- on the server end.
#Since I do not have the write permit, my code fails
subprocess.Popen("a.exe")
>>>OSError: [errno 13] permission denied.
I am not sure why subprocess changes my folder permission on the server end. So I try to use sudo mode as:
subprocess.Popen("sudo", "a.exe")
As I expected, this code work locally only.
So can anyone give me some help on why subprocess will remove my write permission?
Thanks!
In windows, you can run it with command:
subprocess.Popen("runas /user:Admin a.exe")

Categories