NameError: name 'myconf' is not defined - python

I am working on web2py image blog.
I am unable to understand these errors:
Internal error
Ticket issued: images/127.0.0.1.2016-11-22.16-44-39.95144250-6a2e-4648-83f9-aa55873e6ae8
Error ticket for "images"
Ticket ID
127.0.0.1.2016-11-22.16-44-39.95144250-6a2e-4648-83f9-aa55873e6ae8
type 'exceptions.NameError'> name 'myconf' is not defined
Version
web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
Python Python 2.7.12: /usr/bin/python (prefix: /usr)
Traceback (most recent call last):
File "/home/sonu/Software/web2py /gluon/restricted.py", line 227, in restricted
exec ccode in environment
File "/home/sonu/Software/web2py /applications/images/models/menu.py", line 17, in
response.meta.author = myconf.get('app.author')
NameError: name 'myconf' is not defined

This post seems to be discussed here.
resolved/work around

I fixed this very same problem as follows:
I removed models/menu.py, and then the problem appears to be solved.
=> Remeber delete the models/menu.py

Related

viewer error when running the stokesCavity.py example

Running Manjaro stable with python-3.9 and python-fipy-3.4.2.1-1.
Just got started with FiPy, ultimately interested in writing single and two-phase flow code. Naturally I tried to run examples/flow/stokesCavity.py (stripped down from all rst text) with: python stokesCavity.py and it throws the following error:
Traceback (most recent call last):
File "/home/zbinkz/HGST/Projects/Python/fipy/examples/flow/stokesCavity.py", line 117, in <module>
viewer = Viewer(vars=(pressure, xVelocity, yVelocity, velocity),
File "/usr/lib/python3.9/site-packages/fipy/viewers/__init__.py", line 130, in Viewer
raise ImportError("Failed to import a viewer: %s" % str(errors))
ImportError: Failed to import a viewer: ["matplotlib: True is not a valid value for orientation; supported values are None, 'vertical', 'horizontal'", "mayavi: No module named 'enthought'"]
I tinkered with different values for FIPY_VIEWER in the viewer command at line 117 reported above but still get the same error. At this very early stage with FiPy I'm clueless, anybody know how to fix this?
Thanks :)
In this line, change
... viewer = Viewer(vars=(pressure, xVelocity, yVelocity, velocity),
... xmin=0., xmax=1., ymin=0., ymax=1., colorbar=True)
to
... viewer = Viewer(vars=(pressure, xVelocity, yVelocity, velocity),
... xmin=0., xmax=1., ymin=0., ymax=1., colorbar='vertical')
I've filed a ticket to correct this.

Attribute Error: module 'provider' has no attribute 'getDataFiles'

I'm running a code and it gives me an error I can't solve !
how can I add the missing attribute?
the relevant part of the code :
ALL_FILES = provider.getDataFiles('indoor3d_sem_seg_hdf5_data/all_files.txt') #line 63
room_filelist = [line.rstrip() for line in open('indoor3d_sem_seg_hdf5_data/room_filelist.txt')]
The error:
Traceback (most recent call last):
File "E:\Research\Codes\pointnet\pointnet-master\sem_seg\train.py", line 63, in <module>
ALL_FILES = provider.getDataFiles('indoor3d_sem_seg_hdf5_data/all_files.txt')
AttributeError: module 'provider' has no attribute 'getDataFiles'
First, check if you have import provider in your code, you can also do from model import *
I found out that you are using pointnet. So I search the source code and I found this method is:
def getDataFiles(list_filename):
return [line.rstrip() for line in open(list_filename)]
You can search your library for this method. It might not be in the provider.py
You could just added this method to your code. But the best idea is to search for it.
For you case, the provider.py should be at \pointnet\pointnet-master\, and there is also a train.py at that location.
Problem solved ! All I had to do is to copy the provider.py file into the sem.seg.py file which I used. It appears it couldn't find it in the previous file.

SRFax NameError: name 'suds' is not defined

I've been using a community-made fax api (https://github.com/raparri01/srfax-api-python) in Python but I've been stuck on this error message.
Traceback (most recent call last):
...
File "...srfax_api_python\srfax\srfax.py", line 59, in __init__
self.client = suds.client.Client(self.url)
NameError: name 'suds' is not defined
I basically used the code below:
from srfax_api_python.srfax import srfax
srfax_client = srfax.SRFax(<SRFAX_ACCESS_ID>,
<SRFAX_ACCESS_PWD>,
caller_id=<SRFAX_CALLER_ID>,
sender_email=<SRFAX_SENDER_EMAIL>)
fax_id = srfax_client.queue_fax('+11234567', '/path/to/fax/file')
status = srfax_client.get_fax_status(fax_id)
I've used pip to install suds-jurko, which was noted in the requirements.txt file of the repo. I also changed the name of my copy of the repo to srfax_api_python because I couldn't import srfax-api-python. Also, the error occurs when I create srfax_client object, and the file that I create this object in is in the same folder as the srfax_api_python folder. Could someone point me in the right direction?
All help is greatly appreciated

Python : NameError: global name 'GetText' is not defined

I have been stuck with this error for a couple of hours now. Not sure what is wrong. Below is the piece of code
NameError: global name 'GetText' is not defined
class BaseScreen(object):
def GetTextFromScreen(self, x, y, a, b, noofrows = 0):
count = 0
message = ""
while (count < noofrows):
line = Region(self.screen.x + x, self.screen.y + y + (count * 20), a, b)
message = message + "\n" + line.text()
count += 1
return message
class HomeScreen(BaseScreen):
def GetSearchResults(self):
if self.screen.exists("Noitemsfound.png"):
return 'No Items Found'
else:
return self.GetTextFromScreen(36, 274, 680, 20, 16)
class HomeTests(unittest.TestCase):
def test_001S(self):
Home = HomeScreen()
Home.ResetSearchCriteria()
Home.Search("0009", "Key")
self.assertTrue("0009" in Home.GetSearchResults(), "Key was not returned")
Basescreen class has all the reusable methods applicable across different screens.
Homescreen inherits Basescreen.
In HomeTests test case class, the last step is to Home.GetSearchResults() which in turn calls a base class method and the error.
Note:
I have another screenclass and testcaseclass doing the same which works without issues.
I have checked all the importing statements and is ok
'GetText' in the error message is the name of method initially after which i changed it to GetTextFromScreen
Error message is still pointing to a line 88 in code which is not there any more. Module import/reloading issue?
Try clearing out your *.pyc files (or __pycache__ if using 3+).
You asked:
Error message is still pointing to a line 88 in code which is not there any more. Module import/reloading issue?
Yes. The traceback (error messages) will show the current (newest saved) file, even if you haven't run it yet. You must reload/reimport to get the new file.
The discrepancy comes from the fact that traceback printouts read from the script file (scriptname.py) saved on your drive. However, the program is run either from the module saved in memory, or sometimes from the .pyc file. If you fix an error by changing your script, and save it to your drive, then the same error will still occur if you don't reload it.
If you're running interactively for testing, you can use the reload function:
>>> import mymodule
>>> mymodule.somefunction()
Traceback (most recent call last):
File "mymodule.py", line 3, in somefunction
Here is a broken line
OhNoError: Problem with your file
Now, you fix the error and save mymodule.py, return to your interactive session, but you still get the error, but the traceback shows the fixed line
>>> mymodule.somefunction()
Traceback (most recent call last):
File "mymodule.py", line 3, in somefunction
Here is the fixed line
OhNoError: Problem with your file
So you have to reload the module:
>>> reload(mymodule)
<module 'mymodule' from '/path/to/mymodule.py'>
>>> mymodule.somefunction()
Success!

How to interact with pynessus

I am using http://code.google.com/p/pynessus/ so that I can interact with nessus using python but I run into problems trying to connect to the server. I am not sure what I need to set pynessus too?
I try connecting to the server using the following syntax as directed by the documentation on the site but I receive the following error:
n = pynessus.NessusServer(localhost, 8834, root, password123)
Error:
root#bt:~/Desktop# ./nessus.py
Traceback (most recent call last):
File "./nessus.py", line 634, in
n = pynessus.NessusServer(localhost, 8834, root, password123)
NameError: name 'pynessus' is not defined
The problem is that you didn't import the pynessus module. To solve this problem, simply place the downloaded pynessus.py in the same folder as your Python script and add the line
import pynessus
at the top of that script. You can reference the pynessus library in your script only after that line.

Categories

Resources