Tag: programming

macbookOS XSecurityUncategorized

When Was The Password Last Changed On This Mac?

In one more of these wonderful scripts that can do crazy things,  philastokes from APPLEWRITERHELPER, has handed you the keys to the kingdom. With this simple script, you can find our the last time the passwords for a set number of users was changed on a Mac running OS. And that right from your Terminal.

Sometimes it can be useful to know when the user’s password was last changed. For example, you might want to enforce a policy of having users (or yourself!) change login passwords after a given period. Alternatively, if you or one of your users is experiencing login difficulties, you might want to check that the password […]

#one liner command line to get last password set times for all users on the mac

# see http://applehelpwriter.com/2018/03/14/6228
echo; echo Password Last Changed:; u=$(dscl . list /Users | egrep -v ‘^_|daemon|nobody’); for i in $u; do printf \\n$i\\t; currentUser=$i;t=$(dscl . read /Users/”$currentUser” | grep -A1 passwordLastSetTime | grep real | awk -F’real>|</real’ ‘{print $2}’); date -j -f %s “$t” 2> /dev/null; done

via how to find when the login password was last changed —

Advertisements
Little TipsPythonWeb Development

Python, AttributeError: ‘module’ object has no attribute ‘config’

Four years ago, when I first started learning Python, I came across a problem that would later on become a “Famous Question” on StackOverflow. You may be reading this article because you encountered the same problem.

Traceback (most recent call last): File “C:\Users\myname\documents\visual studio 2010\Projects\PythonApplication 1\PythonApplication1\RunSikuliOnVM.py”, line 97, in logging.config.dictConfig(LOG_DICT_CONFIG_OnVM) AttributeError: ‘module’ object has no attribute ‘config’ Press any key to continue . . .

So, I will quickly suggest you check what turned out to be my problem.

I had imported a module into my code and later on made reference to that module by calling a specific attribute, but there was no such attribute in the module. Or at least so thought my Python interpreter. The quick fix for the error that I had gotten turned out to clear the cache of my interpreter. An example of how to do that with an interpreter is in the documentation for PyCharm.

This seems to be what is meant by the Python 3 documentation when it warns that “multiple evaluations of the same attribute reference may yield different objects.” I extrapolate and conclude that the error I am observing is somewhat of a “different” result I am getting.

Now for those interested in understanding the AttributeError for its own sake, another part of the Python documentation describes the exception in these terms:

exception AttributeError :Raised when an attribute reference (see Attribute references) or assignment fails. (When an object does not support attribute references or attribute assignments at all, TypeError is raised.)

 

The problem with the case at hand is that the config module does have a config attribute. This is why I posit that it is the caching issue that is the problem here since the interpreter may be referring to a totally different module than the logging module your code may be calling in this instance.

Note: This article is still in development even though it has been published to offer some beginning of a solution to those dealing with the AttributeError: ‘module’ object has no attribute ‘config’ exception.