I am currently setting up a django site to run on IIS, however I am running into an issue with the USZipCodes python module, When it goes to call the USZipCodes module if gets an access denied error.
I have confirmed all folders regarding this EXCEPT the systemprofile folder has proper permissions for the IIS_IUSRS profile. I would do the systemprofile as well but it just give me more errors and I would prefer not to
This module works fine when not IIS, through CMD it works fine, it is only when using IIS to run the app does this occur.
I suspect I may just have the cut the module out but I would prefer not too
Error Log:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Python310\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\inetpub\wwwroot\Apps\scituateApp\.\tickets\views.py", line 286, in push
json_client['street_name'], zco(json_client['zip']), json_client['state'], json_client['zip'],
File "C:\inetpub\wwwroot\Apps\scituateApp\.\tickets\views.py", line 15, in zco
search = SearchEngine()
File "C:\Python310\lib\site-packages\uszipcode\search.py", line 153, in __init__
self._download_db_file_if_not_exists()
File "C:\Python310\lib\site-packages\uszipcode\search.py", line 173, in _download_db_file_if_not_exists
download_db_file(
File "C:\Python310\lib\site-packages\uszipcode\db.py", line 33, in download_db_file
Path(db_file_path).parent.mkdir(parents=True, exist_ok=True)
File "C:\Python310\lib\site-packages\pathlib_mate\pathlib2.py", line 1614, in mkdir
_try_except_filenotfounderror(_try_func, _exc_func)
File "C:\Python310\lib\site-packages\pathlib_mate\pathlib2.py", line 117, in _try_except_filenotfounderror
try_func()
File "C:\Python310\lib\site-packages\pathlib_mate\pathlib2.py", line 1605, in _try_func
self._accessor.mkdir(self, mode)
File "C:\Python310\lib\site-packages\pathlib_mate\pathlib2.py", line 593, in wrapped
return strfunc(str(pathobj), *args)
PermissionError: [WinError 5] Access is denied: 'C:\\Windows\\system32\\config\\systemprofile\\.uszipcode'
Figured I would follow up. After quite some hours I was able to resolve the issue.
When you setup the IIS, it creates a local group called IIS_LUSRS. You must add the user (local or domain) that you log into to run IIS to this local groups (can be done through the lusrmgr.msc program). Then after this is done, allow that group modify and write privs on the python site package pathlib and the system profile in system 32.
This is not the best solutions, but it fixed it for me...
Related
I am trying to create a new folder inside of Azure http trigger folder, in order to receive some files from an API call and save them based on the name.
config_country_folder = context.function_directory+"/config/"+country.upper()
os.makedirs(config_country_folder, exist_ok=True)
logging.info('Config folder was added')
this part is inside the __init__.py of the trigger, and it's working locally.
however, once deployed and tested, the following error of code 500 occurred:
Result: Failure Exception: OSError: [Errno 38] Function not
implemented: '/home/site/wwwroot/HttpTrigger1/config' Stack: File
"/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py",
line 452, in _handle__invocation_request call_result = await
self._loop.run_in_executor( File
"/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in
run result = self.fn(*self.args, **self.kwargs) File
"/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py",
line 718, in _run_sync_func return
ExtensionManager.get_sync_invocation_wrapper(context, File
"/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py",
line 215, in _raw_invocation_wrapper result = function(**args) File
"/home/site/wwwroot/HttpTrigger1/init.py", line 33, in main
os.makedirs(config_country_folder, exist_ok=True) File
"/usr/local/lib/python3.9/os.py", line 215, in makedirs makedirs(head,
exist_ok=exist_ok) File "/usr/local/lib/python3.9/os.py", line 225, in
makedirs mkdir(name, mode)
The issue is over the makedirs, and I went through the web, which they advised on using the context of the function to create folders. however the error occurred.
Also I was checking this link on using tempfile library, but this is not what I need here.
I am stuck in this setup for almost a week now. Hope that someone can guide me through it.
Setup
I have setup an IIS Server running Flask python code. (Using wfastcgi.py )
I have configured the Application Pool Identity to my own account. (Admin Permission)
I have changed all the files permission that are needed for this web deployment to "Everyone" - Full Control(Read,Write,Execute). (I understand the security risks, this is my staging environment.)
Web server is running fine and i have checked using the bottom code to know my python permission is administrator.
def am_i_admin():
try:
is_admin = os.getuid() == 0
except AttributeError:
is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
if is_admin == True:
return "ADMIN"
else:
return "USER"
Problem Statement
I am trying to run administrator priv code on my flask IIS server which allow user within the same network to execute; such as
subprocess.run(['ipconfig'], stdout=subprocess.PIPE)
pyautogui.screenshot() #which take a screenshot of the web server and send over to the client.
I ran on my local jupyter notebook, and the above functions worked perfectly well.
But it failed to run on the IIS flask server.
I have also tried to setup pyautogui on flask server (stand alone without IIS), it worked.
What is the issue with the IIS server ?? Or are there more things that i need to configure. Are there security features that I can disable ?
Subprocess error message:
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\my_app.py", line 58, in <module>
out = os.popen("ipconfig").read()
File "c:\users\aspnet\anaconda3\lib\os.py", line 990, in popen
bufsize=buffering)
File "c:\users\aspnet\anaconda3\lib\subprocess.py", line 753, in __init__
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File "c:\users\aspnet\anaconda3\lib\subprocess.py", line 1090, in _get_handles
errwrite = _winapi.GetStdHandle(_winapi.STD_ERROR_HANDLE)
OSError: [WinError 6] The handle is invalid
StdOut:
StdErr:
pyautogui error:
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "c:\users\aspnet\anaconda3\lib\site-packages\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\my_app.py", line 45, in <module>
pyautogui.screenshot()
File "c:\users\aspnet\anaconda3\lib\site-packages\pyscreeze\__init__.py", line 135, in wrapper
return wrappedFunction(*args, **kwargs)
File "c:\users\aspnet\anaconda3\lib\site-packages\pyscreeze\__init__.py", line 427, in _screenshot_win32
im = ImageGrab.grab()
File "c:\users\aspnet\anaconda3\lib\site-packages\PIL\ImageGrab.py", line 44, in grab
include_layered_windows, all_screens
OSError: screen grab failed
StdOut:
StdErr:
File "c:\users\aspnet\anaconda3\lib\site-packages\PIL\ImageGrab.py", line 44, in grab
include_layered_windows, all_screens
OSError: screen grab failed
To resolve the issue set stderr and stdin to subprocess.PIPE:
['where', 'wkhtmltopdf'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].strip()
Reference: https://github.com/foliojs/pdfkit/issues/714
File "c:\users\aspnet\anaconda3\lib\site-packages\PIL\ImageGrab.py", line 44, in grab
include_layered_windows, all_screens
OSError: screen grab failed
Use below code:
from PIL import ImageGrab
OR
from PIL import Image
I am a newbie in Toil and AWS trying to run HelloWorld.py example in the Toil Document. I have already successfully installed toil and related python packages on my local mac laptop and have setup my account at AWS. I have created a small leader/worker cluster
$ cgcloud create-cluster toil -s 2 -t m3.large
and started it:
$ cgcloud ssh toil-leader
This changed my screen prompt to:
mesosbox#ip-172-31-25-135:~$
Then from an other window on my mac, I started the Toil HellowWorld example with with command:
$ python2.7 HelloWorld.py --batchSystem=mesos --mesosMaster=mesos-master:5050 aws:us-west-2:my-aws-jobstore
And I got the following output:
Apples-Air 2017-06-02 19:30:53,524 MainThread INFO toil.lib.bioio: Root logger is at level 'INFO', 'toil' logger at level 'INFO'.
Apples-Air 2017-06-02 19:30:53,524 MainThread INFO toil.lib.bioio: Root logger is at level 'INFO', 'toil' logger at level 'INFO'.
Apples-Air 2017-06-02 19:30:54,852 MainThread WARNING toil.jobStores.aws.jobStore: Exception during panic
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 209, in initialize
self.destroy()
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 1334, in destroy
self._bind(create=False, block=False)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 241, in _bind
versioning=True)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 721, in _bindBucket
bucket = self.s3.get_bucket(bucket_name, validate=True)
File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 502, in get_bucket
return self.head_bucket(bucket_name, headers=headers)
File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 535, in head_bucket
raise err
S3ResponseError: S3ResponseError: 403 Forbidden
Traceback (most recent call last):
File "helloWorld.py", line 22, in <module>
print(Job.Runner.startToil(j, options)) #Prints Hello, world!, ….
File "/usr/local/lib/python2.7/site-packages/toil/job.py", line 740, in startToil
with Toil(options) as toil:
File "/usr/local/lib/python2.7/site-packages/toil/common.py", line 614, in __enter__
jobStore.initialize(config)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 209, in initialize
self.destroy()
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 206, in initialize
self._bind(create=True)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 241, in _bind
versioning=True)
File "/usr/local/lib/python2.7/site-packages/toil/jobStores/aws/jobStore.py", line 721, in _bindBucket
bucket = self.s3.get_bucket(bucket_name, validate=True)
File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 502, in get_bucket
return self.head_bucket(bucket_name, headers=headers)
File "/usr/local/lib/python2.7/site-packages/boto/s3/connection.py", line 535, in head_bucket
raise err
boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
Please help.
Thanks.
---John
I realize that this answer is a little late. One problem I notice is with the mesosMaster argument.
Instead, your command should have look like
python2.7 HelloWorld.py --batchSystem=mesos --mesosMaster=172.31.25.135:5050 aws:us-west-2:my-aws-jobstore
Notice that I replaces mesos-master with the actual IP address from
mesosbox#ip-172-31-25-135:~$
Hopefully in the future, one will not need to pass this argument at all, however this is not yet implemented as of 26 July 2017.
Also for further problems with Toil you will probably have better luck posting a new issue to the Toil Github page.
I just installed scrapyd on Ubuntu (with apt-get tool). However, without doing any change to the configuration, when I launched "scrapyd" I got the following error:
(! 397)-> scrapyd
Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/application/app.py", line 642, in run
runApp(config)
File "/usr/lib/python2.7/dist-packages/twisted/scripts/twistd.py", line 23, in runApp
_SomeApplicationRunner(config).run()
File "/usr/lib/python2.7/dist-packages/twisted/application/app.py", line 376, in run
self.application = self.createOrGetApplication()
File "/usr/lib/python2.7/dist-packages/twisted/application/app.py", line 441, in createOrGetApplication
application = getApplication(self.config, passphrase)
--- <exception caught here> ---
File "/usr/lib/python2.7/dist-packages/twisted/application/app.py", line 452, in getApplication
application = service.loadApplication(filename, style, passphrase)
File "/usr/lib/python2.7/dist-packages/twisted/application/service.py", line 405, in loadApplication
application = sob.loadValueFromFile(filename, 'application', passphrase)
File "/usr/lib/python2.7/dist-packages/twisted/persisted/sob.py", line 210, in loadValueFromFile
exec fileObj in d, d
File "/usr/lib/pymodules/python2.7/scrapyd/txapp.py", line 3, in <module>
application = get_application()
File "/usr/lib/pymodules/python2.7/scrapyd/__init__.py", line 14, in get_application
return appfunc(config)
File "/usr/lib/pymodules/python2.7/scrapyd/app.py", line 22, in application
poller = QueuePoller(config)
File "/usr/lib/pymodules/python2.7/scrapyd/poller.py", line 13, in __init__
self.update_projects()
File "/usr/lib/pymodules/python2.7/scrapyd/poller.py", line 30, in update_projects
self.queues = get_spider_queues(self.config)
File "/usr/lib/pymodules/python2.7/scrapyd/utils.py", line 18, in get_spider_queues
d[project] = SqliteSpiderQueue(dbpath)
File "/usr/lib/pymodules/python2.7/scrapyd/spiderqueue.py", line 12, in __init__
self.q = JsonSqlitePriorityQueue(database, table)
File "/usr/lib/pymodules/python2.7/scrapyd/sqlite.py", line 95, in __init__
self.conn = sqlite3.connect(self.database, check_same_thread=False)
sqlite3.OperationalError: unable to open database file
Failed to load application: unable to open database file
I am pretty new to Python, I was trying to print the SQlite filename that it tried to open but this file is owned by scrapy user and I try to stay away messing with it. Also, here the content of my configuration:
(! 403)-> cat /etc/scrapyd/conf.d/000-default
[scrapyd]
http_port = 6800
debug = off
#max_proc = 1
eggs_dir = /var/lib/scrapyd/eggs
dbs_dir = /var/lib/scrapyd/dbs
items_dir = /var/lib/scrapyd/items
logs_dir = /var/log/scrapyd
Does anyone have clue about this? Thanks.
I suspect the Scrapyd configuration is referencing files or folders that your system user doesn't have the appropriate permissions to use.
There are at least three potential solutions to this problem:
Change the dbs_dir in the configuration file (/etc/scrapyd/scrapyd.conf) to a location your system user can access.
Change the permissions on /var/lib/scrapyd/dbs to allow users or groups access.
Run scrapyd as another user, as a superuser, or as root.
I am installing openerp at my local server, I have installed it and its dependences but after finishing its installation when i run server 'openerp-server' and acces it using 0.0.0.0:8069/. I got the following error
OpenERP Server Error
Client Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/addons/web/http.py", line 195, in dispatch
response["result"] = method(self, **self.params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/addons/web/controllers/main.py", line 709, in get_list
return db_list(req)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/addons/web/controllers/main.py", line 88, in db_list
dbs = proxy.list()
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/addons/web/session.py", line 31, in proxy_method
result = self.session.send(self.service_name, method, *args)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/addons/web/session.py", line 104, in send
raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)
Server Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/addons/web/session.py", line 90, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/netsvc.py", line 295, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/service/web_services.py", line 122, in dispatch
return fn(*params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/service/web_services.py", line 351, in exp_list
cr = db.cursor()
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/sql_db.py", line 477, in cursor
return Cursor(self._pool, self.dbname, serialized=serialized)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/sql_db.py", line 183, in __init__
self._cnx = pool.borrow(dsn(dbname))
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/sql_db.py", line 378, in _locked
return fun(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130211_002141-py2.7.egg/openerp/sql_db.py", line 433, in borrow
result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
OperationalError: FATAL: role "ghrix" does not exist
I haven't recognize this error.
One more thing , I haven't edit OpenERP server configuration file . And if I have to edit this file then what are those changes.
Thanks.
This error indicates that OpenERP is trying to connect to the PostgreSQL database server using the "ghrix" user, which does not exist. This is probably the user under which you are starting the server.
If you have created a special database user for OpenERP you need to specify it on the command-line using --db_user=DB_USER (and in that case you probably also need --db_host=localhost and --db-password=YOUR_PASSWORD).
If you haven't created any database user yet, the easiest solution is probably to create one named ghrix, e.g.:
$ sudo su - postgres
$ createuser -s ghrix # -s to make a super-user that can create DBs
Note: Use ./openerp-server --help to see all possible startup parameters for the OpenERP server. You can also put the command-line options in a config file: just execute
$ ./openerp-server -s
and then edit the sample config file that is created in $HOME/.openerp_serverrc
Even though the question has been answered, the following is a concise tutorial on installing a production grade OpenERP Server, that also explains how to set up the database, manage access rights and configure your OpenERP installation:
http://www.theopensourcerer.com/2012/02/how-to-install-openerp-6-1-on-ubuntu-10-04-lts/
you should check two case
First case:
$ sudo su - postgres $ createuser -s ghrix
second case
fill the db user and db password in
/odoo/debian/odoo.conf
run odoo with this parameter
./odoo-bin -c /opt/odoo/debian/odoo.conf
If not resolved comment below i try to resolve it