PyAD- Date based attributes Mostly return None - python

Copying from Github-
When I try to adquery or pull an attribute that has a date involved (such as lastLogon, lastLogoff, or even a log off method... the attribute always comes up None. However other attributes seem to work. What am I doing wrong?
user1=aduser.ADUser.from_cn("First Last")
date=user1.get_last_login() //comes back as nonetype
Traceback (most recent call last):
File "<pyshell#80>", line 1, in
date=user1.get_last_login()
File "C:\Users\administrator.RESOURCECENTER\AppData\Local\Programs\Python\Python39\lib\site-packages\pyad\adobject.py", line 407, in get_last_login
return pyadutils.convert_datetime(self.get_attribute('lastLogonTimestamp', False))
File "C:\Users\administrator.RESOURCECENTER\AppData\Local\Programs\Python\Python39\lib\site-packages\pyad\pyadutils.py", line 71, in convert_datetime
high_part = int(adsi_time_com_obj.highpart) << 32
AttributeError: 'NoneType' object has no attribute 'highpart'
Not really well documentation on this issue so not sure what I can try.

Related

Python error vision-1.0.0-py3.10-nspkg.pth:

Whenever I run python I get this error message:
Error processing line 1 of D:\Users\RBS\AppData\Local\Programs\Python\Python310\lib\site-packages\vision-1.0.0-py3.10-nspkg.pth:
Traceback (most recent call last):
File "D:\Users\RBS\AppData\Local\Programs\Python\Python310\lib\site.py", line 186, in addpackage
exec(line)
File "", line 1, in
File "", line 568, in module_from_spec
AttributeError: 'NoneType' object has no attribute 'loader'
What is this error and how to fix it?
Sounds a lot like what I saw at: AttributeError: 'NoneType' object has no attribute 'loader'
Based on their comments what worked for me was going to C:\Users\"username"\anaconda3\envs\"Project name" then looking for a file called "vision-1.0.0-py3.7-nspkg.pth" and deleting it.
Ran into this post before having seen the other one, thought I'd share. Solved the error for me but not sure if removing the files would give any sort of problem later on.

TypeError: 'float' object has no attribute '__getitem__' in Python

I am working on a project in Python. I am a beginner and I am getting this error when I am running the program.
Traceback (most recent call last):
File "E:/Python/1616/checkProfile.py", line 104, in <module>
p.getResults()
File "E:\Python\1616\Profile.py", line 67, in getResults
for i in range(2): self._s[1] += e.getS[1]
TypeError: 'float' object has no attribute '__getitem__'
Error in Line 67
http://pastebin.com/HXvppfmU
to check what are the methods allowed for datatypes,
dir(datatype)
# As for float, try dir(float)
#This will suggest you that there is no method called __getitem__ for float.
# You might be trying to get some data or you are using []/()/{} which is not correct.
Try to post ur code.

How to access the response object using elasticsearch DSL for python

I have the following code:
s = Search(using=Elasticsearch('http://user:passwd#ipaddress'), index="myindex")
q = Q("multi_match", query='some query', fields=['_all'])
s = s.query(q)
response = s.execute()
print('Total %d hits found.' % response.hits.total)
for hit in response:
print(hit.title)
And I get the error:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/elasticsearch_dsl/utils.py", line 102, in __getattr__
return _wrap(self._d_[attr_name])
KeyError: 'title'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "FindImage.py", line 89, in <module>
main(args.image_file)
File "FindImage.py", line 82, in main
query_db([1], [2])
File "FindImage.py", line 77, in query_db
print(hit.title)
File "/usr/local/lib/python3.5/dist-packages/elasticsearch_dsl/utils.py", line 105, in __getattr__
'%r object has no attribute %r' % (self.__class__.__name__, attr_name))
AttributeError: 'Result' object has no attribute 'title'
However that is in direct contradiction to what the docs state:
Docs
What am I doing wrong? How can I correctly extract the hits and my values from the response?
EDIT
Also the response object ist supposed to have a method "toDict" but when I try to call it I again get an AttributeError.
For the "toDict" question, response.to_dict() works for me. Not sure if this behaviour is the same across lib versions.
Apparently the ".title" references an actual column in their example.
When I used hit.doc.FIRSTTAG, FIRSTTAG being a column in MY NoSQL-db it worked.
Still does not explain the missing method, but I am happy with it for now.
So to anyone having the same problem:
Use your own columns names when evaluating the response object e.g. in my example:
for hit in response:
print(hit.doc.FIRSTTAG)

Type error in python 2.7

Traceback (most recent call last):
File "C:\Python27\meanshift.py", line 15, in <module>
roi = frame[r:r+h, c:c+w],
TypeError: 'NoneType' object has no attribute '__getitem__'
Please help me to resolve this error, I am trying to make a region of interest on the first frame to track an object.
Usually I get this kind of errors if I forgot to put a return statement at the end of a function:
def create_array(n):
a = np.array((n,5))
b = create_array(10)
print b[5,1]
Without an explicit return a at the end of the function, it will return None.

AttributeError: 'NoneType' object has no attribute 'endswith'

I am currently working on a Python script that updates a web page. But running the main script generates this error:
<res status='-1'><error message="'NoneType' object has no attribute 'endswith'"><![CDATA[
Traceback (most recent call last):
File "/path/to/file/ws_config.py", line XXXX, in Run
tests = TestList().tests
File "/path/to/file/ws_config.py", line XXXX, in __init__
UpdateTestGroup(None),
File "/path/to/file/ws_config.py", line XXXX, in __init__
test = CT.CurlTest(settings),
File "/path/to/file/config_tests.py", line XXXX, in __init__
self.params.path = os.path.join('/', os.path.join(params.dir, params.file))
File "/usr/lib/python2.6/posixpath.py", line 67, in join
elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'
I cannot past any code because is too long. What I am trying to understand is where the error lays or what part of the code is triggering the AttributeError.
Can you please help me???
The path in the elif is a None and None == '' returns False so the remain will be executed. And backwards, the params.dir is a None. You need to check your code where the params.dir generated to see how the None come.

Categories