Python 2 is trying to import pyhon3 modules, gnome-tweak-tool broken
I can't start gnome-tweak-tool it complains
Traceback (most recent call last):
File "/usr/bin/gnome-tweak-tool", line 22, in <module>
import gi
File "/usr/lib/python3.3/site-packages/gi/__init__.py", line 27, in <module>
from ._gi import _API, Repository
ImportError: /usr/lib/libpyglib-gi-2.0-python3.so.0: undefined symbol: _Py_FalseStruct
It would appear that python2 is trying to import python3 modules. I also get this error with
>python2
>import gi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.3/site-packages/gi/__init__.py", line 27, in <module>
from ._gi import _API, Repository
ImportError: /usr/lib/libpyglib-gi-2.0-python3.so.0: undefined symbol: _Py_FalseStruct
Why is this happening!? I had a similar issue a while back with python2 trying to import a (different) python3 module when trying to install something from the AUR but that was
fixed by doing
export $PYTHONPATH=/usr/lib/python2.7/site-packages
as on login my PYTHONPATH is set as /usr/lib/python3.3/site-packages, however this did not fix the gnome-tweak-tool issue.
my python3 sys.path is
['', '/usr/lib/python3.3/site-packages', '/usr/lib/python33.zip', '/usr/lib/python3.3', '/usr/lib/python3.3/plat-linux', '/usr/lib/python3.3/lib-dynload', '/usr/lib/python3.3/site-packages/setuptools-0.6c11.egg-info', '/usr/lib/python3.3/site-packages/setuptools-0.6c11.egg-info']
and my python2 sys.path is
['', '/usr/lib/python3.3/site-packages', '/usr/lib/python3.3/site-packages/setuptools-0.6c11.egg-info', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info', '/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode']
Whats going wrong!?
Last edited by tbdc (2013-05-16 19:28:28)
@prateek13 Please do not Necro-bump or Power-post
https://wiki.archlinux.org/index.php/Fo … Bumping.22
https://wiki.archlinux.org/index.php/Fo … mpty_Posts
Closing.
Similar Messages
-
I installed gnome-tweak-tool and mesed around for a bit and it no longer works. When I run gnome-tweak-tool It gives the error
$ gnome-tweak-tool
Traceback (most recent call last):
File "/usr/local/bin/gnome-tweak-tool", line 22, in <module>
import gi
I tried installing a version from git, and I think that only messed it up even more. I have no python experience, so im completly in the dark here. Any help/hint would be very much appreciated.
If you need any logs/information just ask.is simple, very simple
you built that package manually, that's why is in /usr/local/bin/gnome-tweak-tool
get rid of it now and install that tool from our repos.
pacman -S gnome-tweak-tool
this is arch, not slackware. we do packages and install them with pacman to keep track of files.
Last edited by wonder (2011-07-17 16:11:13) -
Cannot import Re module into WLST shell
Hello,
I am trying to import re module into WLST shell bu get the error below. Anyone
knows how to go about it.
wls:/(offline)> import re
Traceback (innermost last):
File "<input>", line 1, in ?
ImportError: no module named re
ImportError: no module named re
-VamsiRealized that it is probably because JDK1.4 provides Regular Expression support.
-Vamsi
"Vamsi" <[email protected]> wrote:
>
Hello,
I am trying to import re module into WLST shell bu get the error below.
Anyone
knows how to go about it.
wls:/(offline)> import re
Traceback (innermost last):
File "<input>", line 1, in ?
ImportError: no module named re
ImportError: no module named re
-Vamsi -
Import metadata from BI Admin tool -OBIEE 11g
Hi,
I am trying to import metadata from BI Admin tool 11g (offile- did not start BI services) but it always showing "Connection has failed". I tried ODBC 2.0, ODBC 3.5, OCI11g/10g with different schemas .. But still no luck... I checked all those from Toad and DSN Tests.. then all are successfulll... But in BI Admin Tool only I can not connect to those Datasources.. Where Iam wrong..? any workarounds would be appreciated...
Thanks and Regards,
Sri.
(OBIEE 11.1.1.5, Oracle 11g R2 EE Database, MS Windows XP Professional Edition SP2)ORACLE FOLDER
C:\Oracle\product\11.2.0\client_1\network\admin\sample
We have tnsnames.ora file in this oracle folder coppy that and save it in
C:\Oracle\product\11.2.0\client_1\network\admin
Tnsnames.ora
This tnsname.ora file should contain the details of
Data Source name – ORCL
Host name – xxxx.xxxxxx.com
Portno - 1531 (This port no is default port in oracle)
Service Name – ORCL
OBIEE FOLDER
C:\OBIEE\oraclebi\orainst\config\OracleBIServerComponent\coreapplication
Tnsname.ora (need to have this file in the above path which is same in ORACLE FOLDER)
GOTO – Start – Control panel – Administrative Tool – Data Source(ODBC) in this
1. Goto System DSN tab
2. Select Add at right side
3. A new pop-up window opens – ‘Create New Data Source’
4. Select from the list – Oracle in OraClient11g_Home
5. A pop-up window opens –‘Oracle ODBC Driver Configaration’ in that
6. Data Source name – Mandatory (You can give any name) e.g –ORACLE DSN
7. Description – Optional (you can give r leave it blank).
8. TNS Service Name – HOST:PORT/Data Source Name e.g –xxxx.xxxxxxx.com:1531/ORCL (xxxx.xxxxxx.com may be IP Address also)
9. User ID – Give Database USERID (If you are going to take data from SERVER you have to give Server Data Base USER ID / If you are going to take data from Local Machine use your Local machine database User id ) e.g –USER id – ‘system’ where password is – ‘Manager’ -
Error trying to import python dbxml package
Hi,
I can see a similar thread fro windows (see: Python API setup problem on Windows but I'm having this problem with fedora15 (64bit) / Python2.7 / BDB XML 2.5.16:
I can build and install BDB XML without any problems following the standard documentation. I'm then trying to get the Python API to work.
I followed the instructions and the bsddb3.db library works fine:
#$ python
#>>> from bsddb3.db import *
#>>> print version()
(4, 8, 26)
#>>> exit()
the problem is trying to import dbxml:
#$ python
#>>> from bsddb3.db import *
#>>> from dbxml import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/dbxml.py", line 25, in <module>
dbxml = swigimport_helper()
File "/usr/lib64/python2.7/site-packages/dbxml.py", line 24, in swig_import_helper
return _mod
UnboundLocalError: local variable '_mod' referenced before assignment
#>>>
And if I then try to reimport:
(following directly on from the above snippet)
#>>> from dbxml import *
Segmentation fault
... and python closes.
Any thoughts?
Thanks!
Edited by: 898830 on 23-Nov-2011 11:11
Edited by: 898830 on 23-Nov-2011 11:13Hi,
After an interesting few days I think it is now working! complete reinstall seemed to do it.
Thanks! -
HELP! Downloaded LR5 and when open it shows an error message saying error while trying to change from modules and I can not even import photos. Am I doing something wrong?
I have the same problem, and the solutions in Error changing modules | Lightroom do not work. Even uninstalling and reinstalling a new copy did not solve the problem. As anyone got an idea what other lingering files might be causing the problem?
-
please help me to fix this problems. i can't open my paid study program due to " fail to import cxutils module into python."
I have the same exact error message appearing several times per day but I have not succeeded in finding the source of the problem.
Any ideas guys?
The problem started as soon as I upgraded from Mavericks to Yosemite. -
Jython having issue importing weblogic modules for changing passwords
I am trying to import some WLST modules into a Jython script as outline in the documentation at http://e-docs.bea.com/wls/docs92/config_scripting/config_WLS.html#wp1019971
The strange thing is that it says it is a WLST script, but it appears to be a Jython script. I tried performing this import using WLST interactive mode, but this did not work.
I am passing the passwords as encrypted strings while using the encrypt() function
Here is the script:
import sys
from weblogic.management.security.authentication import UserPasswordEditorMBean
#To be invoked by java -cp /usr/local/bea/wlserver_10.0/common/lib/jython.jar org.python.util.jython
#usage: wlst.sh ResetWLPassword.py <current_pass> <user> <new_pass> <adminServerURL>
#{3DES}/asdfadsf== -
#{3DES}asdfafdsadsf== -
myPass = sys.argv[1]
myUser = sys.argv[2]
newPass = sys.argv[3]
adminServerURL = sys.argv[4]
#Connect
try:
connect('weblogic',myPass,adminServerURL)
except:
print "Could not connect using supplied credentials"
dumpStack()
try:
print "Changing password ..."
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider("DefaultAuthenticator")
atnr.changeUserPassword(myUser,myuser,newPass)
print "Changed password successfully"
except:
print "Password change failed"
dumpStack()
I am receiving the following error message:
java -cp /usr/local/bea/wlserver_10.0/common/lib/jython.jar org.python.util.jython /tmp/ResetWLPassword.py "{3DES}/adsfadsfadsf==" weblogic "{3DES}asdfadsfasd== " t3://localhost:7003
sys-package-mgr: can't create package cache dir, '/usr/local/bea/wlserver_10.0/common/lib/cachedir/packages'
Traceback (innermost last):
File "/tmp/ResetWLPassword.py", line 2, in ?
ImportError: No module named managementblumo wrote:
You are calling org.python.util.jython again instead of weblogic.WLST like I advised in my first post. Invoke WLST (not jython) and pass your values in cleartext. Like I said in my previous post, I was able to execute your script without issue when calling WLST and passing cleartext values (I did have to modify one line to due a bug in your script -- see my prior posts).This seems to work in terms of getting the code to run, but there is still a problem with passing the arguments to the changeUserPassword() method.
I entered the sequence of commands in the script manually into WLST and it works without issue. It even works without the import, which is strange that Oracle includes it in their documentation.
I am going to post the code here, perhaps there is something wrong syntax-wise with the way I am authenticating, but I can't put my finger on it.
import sys
from weblogic.management.security.authentication import UserPasswordEditorMBean
myPass = sys.argv[1]
myUser = sys.argv[2]
newPass = sys.argv[3]
adminServerURL = sys.argv[4]
#Connect
try:
connect(myUser,myPass,adminServerURL)
except:
print "Could not connect using supplied credentials"
dumpStack()
try:
print "Changing password ..."
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider("DefaultAuthenticator")
#atnr.changeUserPassword('weblogic','weblogic','12345678')
atnr.changeUserPassword(myUser,myPass,newPass)
print "Changed password successfully"
except:
print "Password change failed"
dumpStack()
throws:
Connecting to t3://localhost:7003 with userid weblogic ...
This Exception occurred at Mon Feb 23 11:50:18 PST 2009.
javax.naming.AuthenticationException [Root exception is java.lang.SecurityException: User: weblogic, failed to be authenticated.]
at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:42)
at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:773)
at weblogic.jndi.WLInitialContextFactoryDelegate.pushSubject(WLInitialContextFactoryDelegate.java:670)
at weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFactoryDelegate.java:466)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:373)
at weblogic.jndi.Environment.getContext(Environment.java:307)
at weblogic.jndi.Environment.getContext(Environment.java:277)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at weblogic.management.scripting.WLSTHelper.populateInitialContext(WLSTHelper.java:498)
at weblogic.management.scripting.WLSTHelper.initDeprecatedConnection(WLSTHelper.java:551)
at weblogic.management.scripting.WLSTHelper.initConnections(WLSTHelper.java:303)
at weblogic.management.scripting.WLSTHelper.connect(WLSTHelper.java:201)
at weblogic.management.scripting.WLScriptContext.connect(WLScriptContext.java:60)
at weblogic.management.scripting.utils.WLSTUtil.initializeOnlineWLST(WLSTUtil.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:160)
at org.python.core.PyMethod.__call__(PyMethod.java:96)
at org.python.core.PyObject.__call__(PyObject.java:248)
at org.python.core.PyObject.invoke(PyObject.java:2016)
at org.python.pycode._pyx6.connect$1(<iostream>:16)
at org.python.pycode._pyx6.call_function(<iostream>)
at org.python.core.PyTableCode.call(PyTableCode.java:208)
at org.python.core.PyTableCode.call(PyTableCode.java:404)
at org.python.core.PyTableCode.call(PyTableCode.java:287)
at org.python.core.PyFunction.__call__(PyFunction.java:179)
at org.python.pycode._pyx18.f$0(/tmp/ResetWLPassword.py:20)
at org.python.pycode._pyx18.call_function(/tmp/ResetWLPassword.py)
at org.python.core.PyTableCode.call(PyTableCode.java:208)
at org.python.core.PyCode.call(PyCode.java:14)
at org.python.core.Py.runCode(Py.java:1135)
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:167)
at weblogic.management.scripting.WLST.main(WLST.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.WLST.main(WLST.java:29)
Caused by: java.lang.SecurityException: User: weblogic, failed to be authenticated.
at weblogic.common.internal.RMIBootServiceImpl.authenticate(RMIBootServiceImpl.java:116)
at weblogic.common.internal.RMIBootServiceImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:479)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:475)
at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:59)
at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:1016)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
Could not connect using supplied credentials
Changing password ...
Password change failed -
[python] setting a variable in a loaded module from the main script
Hi,
I have have two python scripts, one generally controlling my desktop wallpaper, the other downloads the APOD picture from the net and sets it as my wallpaper.
At the moment I can get the wallpaper script to load the apod script as a module to use its functionality.
The problem comes when I try to get the module to recognise variables set from the parent script:
I have both scripts using the variable 'verbose' to control how much output is printed, (which can be set from the command line options).
How do I get the 'verbose' variable in the imported module to be the same as the variable set by the script?
I can get it into an imported function using a keyword assignment when called, 'download(verbose=options.verbose)', but this is forgotten when other functions are called.
I have also tried making it a global variable.
I assume it is because I am importing the module and setting the default value before the main script sets its value, but I cant see a way round this.
Any ideas?
Many thanks,
Drewsimplicity:
test1.py
#!/usr/bin/python3
__version__ = 1
from optparse import OptionParser, OptionGroup, SUPPRESS_HELP
import test2
def_msg = 3
def function1(msg=def_msg):
print('1 message level here is {0}' .format(msg))
def function2():
print('2 message level here is {0}' .format(msg))
def function3(msg=def_msg):
msg = def_msg
print('3 message level here is {0}' .format(msg))
def function4():
print('4 message level here is {0}' .format(msg))
def main(msg=def_msg):
print('m message level here is {0}' .format(msg))
function1(msg=msg)
function2()
function3()
function4()
test2.main(msg=msg)
function2()
if __name__ == "__main__":
parser = OptionParser(usage = "usage: %prog [options] command", version="%prog {0}" .format(__version__),
description = "Test script 1.")
parser.set_defaults()
standard = OptionGroup(parser, "Standard Options")
## Standard Options
standard.add_option("-q", "--quiet",
action="store_true", dest="quiet", default=False, #help=SUPPRESS_HELP)
help="only display warnings and errors")
standard.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False, #help=SUPPRESS_HELP)
help="display all output")
standard.add_option("--debug",
action="store_true", dest="debug", default=False, #help=SUPPRESS_HELP)
help="debug mode: detailed output of commands")
standard.add_option("--really-quiet",
action="store_true", dest="reallyquiet", default=False, help=SUPPRESS_HELP)
#help="only display errors")
standard.add_option("--silent",
action="store_true", dest="silent", default=False, help=SUPPRESS_HELP)
#help="don't display any output")
parser.add_option_group(standard)
(options, args) = parser.parse_args()
## message level
if options.debug == True:
msg = 5
elif options.verbose == True:
msg = 4
elif options.quiet == True:
msg = 2
elif options.reallyquiet == True:
msg = 1
elif options.silent == True:
msg = 0
else:
msg = 3
main(msg=msg)
test2.py
#!/usr/bin/python3
__version__ = 1
from optparse import OptionParser, OptionGroup, SUPPRESS_HELP
#from test1 import msg
def_msg = 3
#msg = 3
def function1(msg=def_msg):
print('1 message level here is {0}' .format(msg))
def function2(msg=def_msg):
print('2 message level here is {0}' .format(msg))
def function3():
print('3 message level here is {0}' .format(msg))
def main(msg=def_msg):
#from test1 import msg
#import test1
#msg = test1.msg
print('m message level here is {0}' .format(msg))
function1(msg=msg)
function2()
function3()
if __name__ == "__main__":
parser = OptionParser(usage = "usage: %prog [options] command", version="%prog {0}" .format(__version__),
description = "Test script 2.")
parser.set_defaults()
standard = OptionGroup(parser, "Standard Options")
## Standard Options
standard.add_option("-q", "--quiet",
action="store_true", dest="quiet", default=False, #help=SUPPRESS_HELP)
help="only display warnings and errors")
standard.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False, #help=SUPPRESS_HELP)
help="display all output")
standard.add_option("--debug",
action="store_true", dest="debug", default=False, #help=SUPPRESS_HELP)
help="debug mode: detailed output of commands")
standard.add_option("--really-quiet",
action="store_true", dest="reallyquiet", default=False, help=SUPPRESS_HELP)
#help="only display errors")
standard.add_option("--silent",
action="store_true", dest="silent", default=False, help=SUPPRESS_HELP)
#help="don't display any output")
parser.add_option_group(standard)
(options, args) = parser.parse_args()
## message level
if options.debug == True:
msg = 5
elif options.verbose == True:
msg = 4
elif options.quiet == True:
msg = 2
elif options.reallyquiet == True:
msg = 1
elif options.silent == True:
msg = 0
else:
msg = 3
main(msg=msg)
else:
msg = def_msg
I think I understand why it gives the results it does when run as 'test1.py -v'
I was just wondering if there was an easier way to get the second script to take and remember the variable without having to write variable=value into the function call every single time? However this is the only way I have found so far.
The actual code:
wallpaper.py:
#!/usr/bin/python3
#Filename: wallpaper.py
__version__ = '6.2.0'
import os, sys
from optparse import OptionParser, OptionGroup, SUPPRESS_HELP
#import warnings
import random
#import apod
##### CONFIG #####
## Global Variables
root = '/home/wallpaper'
feh_wallpaper_file = os.path.expanduser('~/.fehbg')
filter_file = os.path.expanduser('~/.config/openbox/wallpaper/mask')
config_path = os.path.expanduser('~/.config/openbox/wallpaper')
list_default = 'default-list'
list_alt = 'alt-list'
menu_default = 'menu-folders'
menu_alt = 'alt-menu'
lockfile='/tmp/wallpaper.lock'
valid_list_list = 'alt-list', 'default-list'
def_msg = 3
##### LOCK v2.2 #####
def LockScript(fun, lock=lockfile, msg=def_msg):
"""Locks the script before starting a function."""
if msg >= 5:
print('Lock :: Locking Script')
from os import O_CREAT, O_EXCL
try:
fd = os.open(lock, O_CREAT+O_EXCL)
if msg >= 5:
print('Lock :: created lock file')
except OSError:
if msg >= 1:
print('Error :: Already running function {0}...' .format(fun))
sys.exit(1)
try:
fun(msg=msg)
finally:
try:
os.remove(lock)
if msg >= 6:
print('Lock :: Removed Lock File')
except:
if msg >= 1:
print('Lock :: Error :: Lockfile missing')
##### CURRENT INFO #####
def get_filter(msg=def_msg):
"""Retrieves the filter."""
f = open(filter_file, 'r')
i = f.read()
f.close()
if msg >= 6:
print('Got Filter :: {0}' .format(i))
return i
def get_info(msg=def_msg):
"""Returns the path and name of the current wallpaper."""
with open(feh_wallpaper_file, 'r') as f:
a = f.read()
b = a[15:-1]
f.close()
name = os.path.basename(b)
try:
import apod
if name == 'apod':
path = os.path.join(apod.archive_folder, apod.thisyear)
w = os.listdir(path)
w.sort()
wnum = len(w) -1
name = w[wnum]
else:
path = os.path.dirname(b)
except:
path = os.path.dirname(b)
if msg >= 5:
print('current wallpaper :: {0} {1}' .format(path, name))
return path, name
def get_next(c, z, msg=def_msg):
"""Gets the next number in the sequence of length z."""
if c == (len(z) - 1):
n = 0
else:
n = c + 1
if msg >= 6:
print('next number is {0}' .format(n))
return n
def get_prev(c, z, msg=def_msg):
"""Gets the previous number in the sequence of length z."""
if c == 0:
p = (len(z) - 1)
else:
p = c - 1
if msg >= 6:
print('previous number is {0}' .format(p))
return p
def current_wallpaper_info(msg=def_msg):
"""Print the details of the current wallpaper."""
name = get_info(msg=msg)[1]
path = get_info(msg=msg)[0]
folder = os.path.basename(path)
mask = get_filter(msg=msg)
try:
import apod
if path.startswith(apod.archive_folder) or name.startswith('APOD'):
title = apod.get_name(fname=name, msg=msg)
print('currently the wallpaper is "{0}", {1}' .format(title, name))
elif not mask == '':
print('currently the wallpaper is {0} from folder {1} using mask {2}' .format(name, folder, mask))
else:
print('currently the wallpaper is {0} from folder {1}' .format(name, folder))
except:
print('currently the wallpaper is {0} from folder {1}' .format(name, folder))
##### SET WALLPAPER FUNCTIONS #####
def set_filter(i=None, msg=def_msg, mask_file=filter_file):
"""Sets the filter."""
if test:
f = open(mask_file, 'r')
else:
f = open(mask_file, 'w')
if i == None:
if msg >= 5:
print('clearing filter')
if test:
print('exec :: Clear filter')
else:
f.write('')
else:
if msg >= 4:
print('Setting filter as "{0}"' .format(i))
if test:
print('exec :: Writing filter as :: "{0}"' .format(i))
else:
f.write(i)
f.close()
def set_wallpaper(name, path_in=get_info()[0], msg=def_msg):
"""Set the wallpaper."""
spath = path_in.split(':')
path = spath[0]
try:
mask = spath[1]
set_filter(mask, msg=msg)
except:
pass
full = os.path.join(path, name)
if msg >= 4:
print("setting {0} as wallpaper" .format(name))
if test:
print("exec :: feh --bg-scale {0}" .format(full))
else:
os.system("feh --bg-scale {0}" .format(full))
#def set_default(d=default_file):
# """Sets the default walllpaper."""
# set_wallpaper(d[1], d[0])
def set_wallpaper_last(msg=def_msg):
"""Set the wallpaper as the last image."""
## alternativly use "eval `cat ~/.fehbg`"
full = os.path.join(get_info()[0], get_info()[1])
if msg >= 4:
print("setting {0} as wallpaper" .format(full))
if test:
print("exec :: feh --bg-scale {0}" .format(full))
else:
os.system("feh --bg-scale {0}" .format(full))
def change_folder(folder0, mask=None, msg=def_msg):
"""Change Wallpaper folder (optional filter) relative from root dir."""
folder_split = folder0.split(':')
folder = folder_split[0]
path = os.path.join(root, folder)
if not os.path.exists(path): # Path does not exist
if msg >= 1:
print('Fatal Error :: path does not exist')
print('avaliable folders are {0}' .format(avaliable_folders()))
sys.exit()
if msg >= 4:
print('changing folder to {0}' .format(folder))
f1 = os.listdir(path)
try:
if folder_split[1]:
mask = folder_split[1]
f2 = []
for i in f1:
if i.find(mask) > -1:
f2.append(i)
f = f2
if len(f) == 0:
if msg >= 2:
print('Warning :: invalid filter')
raise
set_filter(mask, msg=msg)
else: # print('null mask')
if msg >= 2:
print('Warning :: null filter')
raise
except:
if msg >= 5:
print('No filter used, clearing')
set_filter(msg=msg)
f = f1
if len(f) == 0:
if msg >= 1:
print('Fatal Error :: no files in path')
sys.exit()
r = random.randrange(0,len(f))
if msg >= 5:
print('chosing random number:: {0}' .format(r))
set_wallpaper(f[r], path, msg=msg)
def avaliable_folders(r=root, msg=def_msg):
"""Returns a list of avaliable folders in the root wallpaper directory."""
allfolders = os.listdir(r)
folders = []
for f in allfolders:
if not f.startswith("."):
folders.append(f)
return folders
##### DEFAULT / ALT SEQUENCE LISTS #####
def strip_opt(p):
#q1 = p.replace(' ','')
#q2 = q1.replace('\t','')
#q3 = q2.replace('\n','')
q = p.replace(' ','').replace('\t','').replace('\n','')
return q
def check_list(l, path=config_path, dl=list_default, al=list_alt, msg=def_msg, returnF=False):
"""Checks to see (and returns) valid path to list."""
if l == 'default' or l == 'def' or l == None :
if msg >= 4:
print('using default list')
return os.path.join(path, dl)
elif l == 'alt':
if msg >= 4:
print('using alternative list')
return os.path.join(path, al)
else:
try:
if not os.path.exists(os.path.join(path, l)):
if msg >= 1:
print('Error :: list does not exist')
raise
elif not os.path.isfile(os.path.join(path, l)):
if msg >= 1:
print('Error :: list not a file')
raise
else:
try:
c = valid_list_list.index(l)
if msg >= 6:
print('list name has been validated')
except:
if msg >= 2:
print('Warnimg :: list used has not been vaildated by script')
print('Warnimg :: if valid; add to the list of valid lists')
if msg >= 5:
print('path exists')
return os.path.join(path, l)
except:
if returnF == True:
return False
else:
if msg >= 2:
print('Warning :: using default list')
return os.path.join(config_path, dl)
def get_seq(msg=def_msg):
"""Returns the sequence of current wallpaper and curr position."""
mask = get_filter(msg=msg)
path = get_info(msg=msg)[0]
name = get_info(msg=msg)[1]
list1 = os.listdir(path)
if mask == '':
list0 = list1
else:
list2 = []
for i in list1:
if i.find(mask) > -1:
list2.append(i)
try: # check the filter is currently being used
num = list2.index(name)
#print('wallpaper in filtered list')
list0 = list2
except: # filter is out of date
if msg >= 5:
print('wallpaper not in filtered list... clearing')
list0 = list1
set_filter(msg=msg) # clear filter
list0.sort()
try: # needed if current wallpaper has been removed
num = list0.index(name)
if msg >= 5:
print('current wallpaper info ::')
print('name : {0}, number : {1}' .format(name, num))
return num, list0
except:
if msg >= 1:
print('Error :: get_seq :: Current wallpaper file missing :: name : {0}' .format(name))
return 0, list0
def list_sequence(com='next', seq=None, msg=def_msg):
cname = get_info(msg=msg)[1]
if seq == None:
list_dir = get_info(msg=msg)[0]
list_file = get_seq(msg=msg)[1]
if msg >= 4:
print('Changing wallpaper in sequence using current folder:mask')
else:
## Build a list.
a = check_list(seq, msg=msg)
list_dir = []
list_file = []
with open(a, 'r') as f:
for line in f:
i = line.split(',')
list_dir.append(os.path.join(root, strip_opt(i[0])))
list_file.append(strip_opt(i[1]))
set_filter(msg=msg) # flush mask if using a list
if msg >= 4:
print('Changing wallpaper in sequence using list file')
try:
c = list_file.index(cname)
if msg >= 5:
print('found current wallpaper in list at position {0}' .format(c))
if com == 'random':
n = random.randrange(0, len(list_file))
if msg >= 4:
print('setting random wallpaper from sequence')
elif com == 'prev':
n = get_prev(c, list_file)
if msg >= 4:
print('setting previous wallpaper in sequence')
elif com == 'next':
n = get_next(c, list_file)
if msg >= 4:
print('setting next wallpaper in sequence')
elif com == 'first':
if msg >= 4:
print('setting first wallpaper in sequence')
n = 0
else:
if msg >= 2:
print('Warning :: Unknown commmand')
n = 0
except:
if msg >= 4:
print('Warning :: not found current wallpaper in list / folder')
print('using first file in list / folder')
n = 0
if seq == None:
set_wallpaper(list_file[n], list_dir, msg=msg)
else:
set_wallpaper(list_file[n], list_dir[n], msg=msg)
def toggle_list(d='default', com='toggle', msg=def_msg):
"""Removes the current file from the list."""
a = check_list(d, msg=msg)
file_list = []
mod_file = []
cname = get_info(msg=msg)[1]
cpath = get_info(msg=msg)[0]
if os.path.dirname(cpath) == root:
cdir = os.path.basename(cpath)
elif os.path.dirname(os.path.dirname(cpath)) == root:
cdir = os.path.join(os.path.basename(os.path.dirname(cpath)), os.path.basename(cpath))
else:
print('error')
sys.exit()
cmask = get_filter(msg=msg)
if cmask == '':
cdmask = cdir
else:
cdmask = '{0}:{1}' .format(cdir, cmask)
in_list = False
with open(a) as f:
for line in f:
i = line.split(',')
if cname == strip_opt(i[1]):
if msg >= 6:
print('file in list')
in_list = True
else:
if msg >= 6:
print('file not in list')
file_list.append(strip_opt(i[1]))
mod_file.append('{0} , {1} \n' .format(strip_opt(i[0]), strip_opt(i[1])))
if in_list and com != 'rmfile' :
if msg >= 3:
print('Removed file from list')
if test:
for j in mod_file:
print('writing newline: {0}' .format(j))
else:
with open(a, 'w') as newf:
for j in mod_file:
newf.writelines(j)
elif not in_list and com != 'addfile':
mod_file.append('{0} , {1} \n' .format(cdmask, cname))
if msg >= 3:
print('Added wallpaper to list')
if test:
for j in mod_file:
print('writing newline: {0}' .format(j))
else:
with open(a, 'w') as newf:
for j in mod_file:
newf.writelines(j)
else:
if com == 'addfile':
if msg >= 2:
print('Warning :: File already in list')
elif com == 'rmfile':
if msg >= 2:
print('Warning :: File not in list')
else:
if msg >= 1:
print('Error :: UNKNOWN :: TOG LIST FUNCTION')
##### OPENBOX MENU #####
def gen_obmenu():
import oblib
for i in avaliable_folders():
oblib.item(i, 'wallpaper.py --silent --change {0}' .format(i))
def gen_obmenu_simple(name=None, i=None):
import oblib
if name == None:
oblib.pipe_start()
else:
oblib.menu_start(name, i)
oblib.item('Deafult', 'wallpaper.py --silent --default')
oblib.sep()
oblib.item('APOD', 'wallpaper.py --silent --apod')
oblib.item('APOD Save', 'wallpaper.py --silent --apod-save')
oblib.item('Random', 'wallpaper.py --silent --random')
if name == None:
oblib.pipe_end()
else:
oblib.menu_end()
def gen_obmenu_standard():
import oblib
oblib.pipe_start()
oblib.item('Deafult', 'wallpaper.py --silent --default')
oblib.sep()
oblib.item('APOD', 'wallpaper.py --silent --apod')
oblib.item('APOD Save', 'wallpaper.py --silent --apod-save')
oblib.sep()
oblib.menu_start('Change Set')
obmenu_change_set()
oblib.menu_end()
apod.obmenu_archive_folders(t='menu')
oblib.item('Toggle List', 'wallpaper.py --silent --toggle')
oblib.item('Random', 'wallpaper.py --silent --random')
oblib.pipe_end()
def gen_obmenu_alt():
import oblib
oblib.pipe_start()
oblib.sep('Alt Menu')
obmenu_change_set('alt')
oblib.pipe_end()
def obmenu_change_set(a='default', dl=menu_default, al=menu_alt):
import oblib
menu = check_list(a, dl=dl, al=al, returnF=True)
if menu != False:
f = open(menu, 'r')
for line in f:
i = line.split(',')
oblib.item(strip_opt(i[0]), 'wallpaper.py --change {0}' .format(strip_opt(i[1])))
f.close()
else:
for i in avaliable_folders():
oblib.item(i, 'wallpaper.py --change {0}' .format(i))
##### TEST FUNCTIONS #####
def parser_options():
print('Options are: {0}' .format(options))
print('Args are : {0}' .format(args))
print('Command is : {0}' .format(command))
def meta_info():
if options.meta_source == None:
print('No source specifieed')
else:
print('Script launched from source :: {0}' .format(options.meta_source))
def test_module():
#pass
#print(check_list(args[0]))
new_mod()
def new_mod():
#if path == None:
# print('No path specified, using pwd')
# path = os.curdir
#need_new_name = False
#print('Checking filenames in {0}' .format(path))
#for name in os.listdir(path):
# if name.find(" ") > -1:
# print("Warning :: > < in {0}" .format(name))
# need_new_name = True
# if name.find("'") > -1:
# print("Warning :: >'< in {0}" .format(name))
# need_new_name = True
# if name.find("&") > -1:
# print("Warning :: >&< in {0}" .format(name))
# need_new_name = True
# if name.find('"') > -1:
# print('Warning :: >"< in {0}' .format(name))
# need_new_name = True
# if need_new_name:
# new_name = name.replace('"', "").replace(" ", "_").replace("&", "and").replace("'", "")
# if re_name:
# print("Renaming to new name:: {0}" .format(new_name))
# os.rename(os.path.join(path, name), os.path.join(path, new_name))
# else:
# print("Suggested new name:: {0}" .format(new_name))
# need_new_name = False
pass
##### SANITISE WALLPAPER FILE NAMES #####
def sane_names(path=None, re_name=False, msg=def_msg):
"""Check file names in a path."""
if path == None:
print('No path specified, using pwd')
path = os.curdir
need_new_name = False
print('Checking filenames in {0}' .format(path))
for name in os.listdir(path):
if name.find(" ") > -1:
print("Warning :: > < in {0}" .format(name))
need_new_name = True
if name.find("'") > -1:
print("Warning :: >'< in {0}" .format(name))
need_new_name = True
if name.find("&") > -1:
print("Warning :: >&< in {0}" .format(name))
need_new_name = True
if name.find('"') > -1:
print('Warning :: >"< in {0}' .format(name))
need_new_name = True
if need_new_name:
new_name = name.replace('"', "").replace(" ", "_").replace("&", "and").replace("'", "")
if re_name:
print("Renaming to new name:: {0}" .format(new_name))
os.rename(os.path.join(path, name), os.path.join(path, new_name))
else:
print("Suggested new name:: {0}" .format(new_name))
need_new_name = False
print('File name check complete')
##### MAIN FUNCTION #####
def Main(msg=def_msg):
"""Chooses which command to run."""
if options.direction != None: # a dircetion has been set
list_sequence(com=options.direction, seq=options.whichlist, msg=msg)
elif command == 'last':
set_wallpaper_last(msg=msg)
elif command == 'info':
current_wallpaper_info(msg=msg)
## change folder
elif options.newfolder != None:
change_folder(options.newfolder, msg=msg)
## apod
elif command == 'apod':
#apod.download2(msg=msg, test=test)
try:
import apod
apod.download2(msg=msg, test=test)
except:
pass
elif command == 'apod-save':
#apod.apod_save('today', msg=msg, test=test)
try:
import apod
apod.apod_save('today', msg=msg, test=test)
except:
pass
## list management
elif options.toggle != None:
toggle_list(options.whichlist, com=options.toggle, msg=msg)
## openbox menu
elif command == 'obmenu':
gen_obmenu_standard()
elif command == 'obmenu-simple':
gen_obmenu_simple()
elif command == 'obmenu-alt':
gen_obmenu_alt()
## filename check
elif command == 'sane-name':
sane_names(path=options.sane_path, re_name=options.sane_rename, msg=msg)
## cycle
elif command == 'cycle':
print('ERROR :: function not implemented')
elif command == 'testmod':
test_module()
elif options.whichlist != None: # a list but no direction specified
list_sequence(seq=options.whichlist, msg=msg)
elif command == "TestNone":
print('Test mode null op[tion')
elif command == None: ## no command specified
pass
else:
print('Error :: no valid command found')
##### SCRIPT STARTUP #####
if __name__ == "__main__":
# def parse_change(option, opt_str, value, parser):
# parser.values.command = 'change'
# parser.values.newfolder = value
# def parse_smask(option, opt_str, value, parser):
# parser.values.command = 'set-mask'
# parser.values.mask = value
def parse_cycle(option, opt_str, value, parser):
parser.values.command = 'cycle'
parser.values.interval = value
def parse_msglevel(option, opt_str, value, parser):
parser.values.msg = value
# def parse_addfile(option, opt_str, value, parser):
# parser.values.command = 'addfile'
# parser.values.whichlist = value
# def parse_rmfile(option, opt_str, value, parser):
# parser.values.command = 'rmfile'
# parser.values.whichlist = value
parser = OptionParser(usage = "usage: %prog [options] command", version="%prog {0}" .format(__version__),
description = "Drews Script to the manage wallpapers using feh.")
parser.set_defaults(command=None, whichlist=None, direction=None, toggle=None, newfolder=None)
standard = OptionGroup(parser, "Standard Options")
metaopt = OptionGroup(parser, "Meta Info Options", "Further datails about the script startup useful for debugging")
gapod = OptionGroup(parser, "APOD Options", "Controls for the Astronomy Picture of the Day. ")
obmenu = OptionGroup(parser, "Openbox Menu", "Support for openbox xml menu generation. ")
#groupalt = OptionGroup(parser, "Alternative Wallpapers")
gplist = OptionGroup(parser, "List Support")
namecheck = OptionGroup(parser, "Filename Support")
direction = OptionGroup(parser, "Direction Commands")
## Standard Options
standard.add_option("-q", "--quiet",
action="store_true", dest="quiet", default=False, #help=SUPPRESS_HELP)
help="only display warnings and errors")
standard.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False, #help=SUPPRESS_HELP)
help="display all output")
standard.add_option("--debug",
action="store_true", dest="debug", default=False, #help=SUPPRESS_HELP)
help="debug mode: detailed output of commands")
standard.add_option("--really-quiet",
action="store_true", dest="reallyquiet", default=False, help=SUPPRESS_HELP)
#help="only display errors")
standard.add_option("--silent",
action="store_true", dest="silent", default=False, help=SUPPRESS_HELP)
#help="don't display any output")
standard.add_option('-t', "--test",
action="store_true", dest="test", default=False, #help=SUPPRESS_HELP)
help="test mode :: only print output")
standard.add_option("--test-mod",
action="store_const", const="testmod", dest="command", #help=SUPPRESS_HELP)
help="test mode :: use test function module")
standard.add_option("--test-none",
action="store_const", const="TestNone", dest="command", #help=SUPPRESS_HELP)
help="test mode :: no command specified")
parser.add_option("--info", '-i',
action="store_const", const="info", dest="command",
help="Displays information about the current wallpaper.")
parser.add_option("--last", '-l',
action="store_const", const="last", dest="command",
help="Sets the wallpaper as the last picture")
direction.add_option('-n', "--next",
action="store_const", const="next", dest="direction",
help="Sets the next wallpaper in the sequence")
direction.add_option('-p', "--prev", '--previous',
action="store_const", const="prev", dest="direction",
help="Sets the previous wallpaper in the sequence")
direction.add_option('-r', '--rand', "--random",
action="store_const", const="random", dest="direction",
help="Sets a random wallpaper from the sequence")
direction.add_option('-1', '--first', "--safe",
action="store_const", const="first", dest="direction",
help="Sets the first wallpaer in the sequence")
gplist.add_option('-d', "--default",
action="store_const", const="default", dest="whichlist",
help="Uses the wallpapers from the default file list")
gplist.add_option("--alt",
action="store_const", const="alt", dest="whichlist",
help="Uses the wallpapers from the alternative list")
parser.add_option("--change", '-c',
metavar="Folder[:Filter]", dest="newfolder",
help="Changes the wallpaper folder, optional filter.")
gapod.add_option('-a', "--apod",
action="store_const", const="apod", dest="command",
help="downloads and sets the wallpaper as todays APOD picture")
gapod.add_option("--apod-save",
action="store_const", const="apod-save", dest="command",
help="Saves todays APOD picture")
# gapod.add_option("--apod-last",
# action="store_const", const="apod-last", dest="command",
# help="Sets the wallpaper as yesterdays APOD picture")
# gapod.add_option("--apod-force",
# action="store_const", const="apod-force", dest="command",
# help="force the download of todays APOD picture")
gplist.add_option("--add-to-list",
action="store_const", const='rmfile', dest='toggle',
help="Adds the current wallpaper to the list.")
gplist.add_option("--remove-from-list",
action="store_const", const='addfile', dest='toggle',
help="Removes the current wallpaper from a list.")
gplist.add_option("--toggle-list", '--toggle',
action="store_const", const='toggle', dest='toggle',
help="Adds/Removes the current wallpaper from a list.")
gplist.add_option("--list",
metavar="LIST", dest='whichlist',
help="Sets which list to use.")
obmenu.add_option("--obmenu",
action="store_const", const="obmenu", dest="command",
help="Prints the standard openbox menu.")
obmenu.add_option("--obmenu-simple",
action="store_const", const="obmenu-simple", dest="command",
help="Prints the simple openbox menu.")
obmenu.add_option("--obmenu-alt",
action="store_const", const="obmenu-alt", dest="command", #help=SUPPRESS_HELP)
help="Prints the alternative openbox menu.")
namecheck.add_option("--name-check",
action="store_const", const="sane-name", dest="command",
help="Checks if wallpaper names are valid.")
namecheck.add_option("--name-path",
metavar="PATH", dest="sane_path", default=None,
help="Which folder to check.")
namecheck.add_option("--rename",
action="store_true", dest="sane_rename", default=False,
help="If to rename invalid files.")
metaopt.add_option("--meta-from",
metavar="Source", dest='meta_source', default=None,
help="Details from where the script was launched from")
parser.add_option_group(direction)
parser.add_option_group(gplist)
parser.add_option_group(gapod)
parser.add_option_group(obmenu)
#parser.add_option_group(standard)
#parser.add_option_group(metaopt)
#parser.add_option_group(namecheck)
(options, args) = parser.parse_args()
test = options.test
#debug = options.debug
#verbose = options.verbose
#quiet = options.quiet
## message level
if options.debug == True:
msg = 5
elif options.verbose == True:
msg = 4
elif options.quiet == True:
msg = 2
elif options.reallyquiet == True:
msg = 1
elif options.silent == True:
msg = 0
else:
msg = 3
#if options.command == None:
# try: # try and find a command
# command = args[0]
# except:
# pass
#else:
# command = options.command
command = options.command
if options.debug:
parser_options()
meta_info()
LockScript(Main, msg=msg) # start the script
else:
pass
apod.py
#!/usr/bin/python3
#Filename: apod.py
__version__ = '3.2.0'
import os, sys
from optparse import OptionParser, OptionGroup, SUPPRESS_HELP
import shutil
from datetime import date
#print('loaded apod')
##### VARIABLES #####
## Files and Paths
#apod_archive_folder = '/home/wallpaper/apod_archive'
archive_folder = '/home/wallpaper/apod_archive'
save_folder = '/home/wallpaper/Space'
tmpdir = '/tmp/wallpaper/apod'
html_file = os.path.join(tmpdir, 'apod-html')
img_file = os.path.join(tmpdir, 'apod-img')
index_file = os.path.join(tmpdir, 'apod-index')
work = os.path.expanduser('~/.config/openbox/apod')
date_file = os.path.join(work, 'apod-date')
apodfile = os.path.join(work, 'apod')
apodlast = os.path.join(work, 'apod-last')
namefile = os.path.join(work, 'apod-names')
video_dir = os.path.join(work, 'apod-videos')
errs = os.path.join(work, 'archive-errors')
dtoday = str(date.today()) # todays date
thisyear = dtoday[:4]
saveprefix = 'APOD-'
## Defaults
def_test = False
def_msg = 3
def_command = None
def_apodset = True
def_archive_apod = True # Keep all APOD pictures
def_clear_apod = False
def_force_apod = False
def_cutoff = None
store_file_list = ''
##### LOCK v2 #####
## Lock v2
def LockScript(fun, lock='/tmp/apod.lock', msg=def_msg):
"""Locks the script before starting a function."""
from os import O_CREAT, O_EXCL
try: # lock the function
fd = os.open(lock, O_CREAT+O_EXCL)
#print('created lock file')
except OSError:
print('Already running function {0}...' .format(fun))
sys.exit(1)
try:
fun(msg)
finally:
try: # release lock
os.remove(lock)
except:
print('Error :: Lockfile missing !!!')
##### DEFINITIONS #####
def get_date(dfile=date_file):
check_file(dfile, create=True, msg=1)
f = open(dfile)
return f.read()
def check_dir(d, create=False, msg=def_msg):
"""Check if path exists."""
if not os.path.exists(d):
if msg > 3:
print('Error : folder missing...')
if create:
try:
os.makedirs(d)
if msg > 3 :
print('...created folder')
return True
except:
print('Fatal Error :: could not create directory {0}' .format(d))
sys.exit()
else:
return False
elif not os.path.isdir(d):
print('Fatal Error :: this is not a directory')
sys.exit()
else:
return True
def check_file(f, create=False, msg=def_msg):
"""Check if path exists."""
if not os.path.exists(f):
#if msg > 3:
# print('Error : file missing...')
if create:
check_dir(os.path.dirname(f), create=create, msg=msg)
if msg > 5:
print('creating file {0}' .format(f))
try:
q = open(f, 'w')
q.write('')
q.close()
return True
except:
if msg >= 1:
print('Fatal Error :: could not create file {0}' .format(f))
sys.exit()
else:
if msg >= 5:
print('file {0} does not exist' .format(f))
return False
else:
if msg >= 5:
print('file {0} exists' .format(f))
return True
def copy_file(ffrom, fto, msg=def_msg, test=def_test):
"""Copy files, from to (with test option)."""
if test:
print('[[copy command: {0} to {1}]]' .format(ffrom, fto))
else:
try:
shutil.copy(ffrom, fto)
except:
if not os.path.exists(ffrom):
print('Warning: error copying file, does not exist')
elif os.path.isdir(ffrom):
print('Fatal Error :: file being copied is a directory!')
sys.exit()
else:
print('Fatal Error :: UNKNOWN ERROR during copy')
sys.exit()
def download_files(hfile=html_file, ifile=img_file, datefile=date_file, msg=def_msg, test=def_test, apodset=def_apodset, day='today', archive_apod=def_archive_apod):
"""Download the APOD html and img."""
import urllib.request
import socket
timeout = 10
socket.setdefaulttimeout(timeout)
if day == 'today':
url = 'http://antwrp.gsfc.nasa.gov/apod/astropix.html'
name = dtoday
year = thisyear
else:
url = 'http://antwrp.gsfc.nasa.gov/apod/ap{0}.html' .format(day)
name = day
if day[:1] == '9' :
name = '19{0}-{1}-{2}' .format(day[:2], day[2:4], day[4:])
else:
name = '20{0}-{1}-{2}' .format(day[:2], day[2:4], day[4:])
year = name[:4]
try:
response = urllib.request.urlopen(url)
html = response.read()
if msg > 3:
print('downloaded html data for {0}' .format(day))
check_file(hfile, create=True, msg=msg)
f = open(hfile, 'wb')
f.write(html)
f.close()
except:
if msg >= 1:
print('ERROR :: page not found :: exiting.')
sys.exit(1)
if day == 'today':
t = open(datefile, 'w')
t.write(dtoday)
t.close()
if msg > 3:
print('updated date file with todays date')
if msg > 3:
print('copying over yesterdays APOD image')
copy_file(apodfile, apodlast, msg=msg, test=test)
found_img = False
with open(hfile, 'r', encoding='latin-1') as g:
for line in g:
if 'IMG SRC' in line:
i = line.split('"')
if msg > 4:
print('found image : {0}' .format(i[1]))
found_img = True
try:
img_responce = urllib.request.urlopen(os.path.join('http://antwrp.gsfc.nasa.gov/apod/', i[1]))
img_data = img_responce.read()
except:
print('error in img download')
check_dir(errs, create=True, msg=1)
check_file(os.path.join(errs, name), create=True, msg=0)
else:
if msg >= 5:
print('read img data')
check_file(ifile, create=True, msg=0)
if msg >= 5:
print('created img file')
with open(ifile, 'wb') as l:
l.write(img_data)
if msg >= 3:
print('downloaded image for {0}' .format(day))
if day == 'today':
copy_file(ifile,apodfile, msg=msg, test=test)
if archive_apod:
apod_archive(msg=msg, test=test, dfile=ifile, year=year, name=name)
if not found_img :
if msg >= 3:
print('video :: not found image line in file from {0}' .format(i))
check_file(os.path.join(video_dir, name), create=True, msg=0)
if day == 'today':
print('Warning : no image line in html file')
copy_file(apodlast,apodfile, msg=msg, test=test)
os.remove(hfile)
os.remove(ifile)
def apod_archive(dfile=img_file, msg=def_msg, test=def_test, year=thisyear, name=dtoday):
"""Archive APOD picture."""
arch_file = os.path.join(archive_folder, year, name)
check_dir(os.path.join(archive_folder, year), msg=msg, create=True)
if check_file(arch_file, create=False, msg=msg):
if msg > 3:
print('APOD picture already archived')
else:
if msg > 3:
print('Archiving APOD picture')
copy_file(dfile, arch_file, msg=msg, test=test)
def apod_save(day='current', sfolder=save_folder, msg=def_msg, test=def_test, prefix=saveprefix):
"""Save APOD picture as best of APOD."""
with open(os.path.expanduser('~/.fehbg'), 'r') as f:
a = f.read()
b = a[15:-1]
f.close()
if day == 'today' or b[-4:] == 'apod':
source = apodfile
sfile = prefix + dtoday
elif day == 'current':
if not (os.path.dirname(b) == archive_folder or os.path.dirname(os.path.dirname(b)) == archive_folder ):
print('picture is not in the recognised apod archive folder')
sys.exit()
source = b
sfile = prefix+ b[-10:]
else:
if msg >= 1:
print('unknown file specified')
sys.exit(1)
if msg > 3:
print('Saving APOD picture to Save folder')
copy_file(source, os.path.join(sfolder, sfile), msg=msg, test=test)
def set_apod(a=apodfile, msg=def_msg, test=def_test, apodset=def_apodset ):
"""Sets the APOD wallpaper."""
if not apodset:
if msg > 3:
print('Skipping setting APOD picture')
else:
if msg > 3:
print('Setting APOD picture')
if test:
print("exec :: feh --bg-scale {0}" .format(a))
else:
os.system("feh --bg-scale {0}" .format(a))
def clear_date(msg=def_msg, test=False):
"""Clears the date file."""
if msg > 3:
print('reseting date')
if not test:
t = open(datefile, 'w')
t.write('')
t.close()
##### APOD NAMES #####
def get_name(fname=None, names=namefile, msg=def_msg, rerun=True, prefix=saveprefix):
"""Returns the name of an APOD file."""
name_index = []
title_index = []
with open(names, 'r') as f:
for line in f:
i = line.split(',', 3)
name_index.append(i[0])
title_index.append(i[3])
if fname == None:
if msg >= 4:
print('getting todays date')
date = get_date()
elif fname.startswith(prefix):
if msg >= 4:
print('removing save prefix from name')
date = fname[len(prefix):]
else:
date = fname
try:
c = name_index.index(date)
return title_index[c][:-2]
except:
if rerun:
if msg >= 2:
print('Warning :: name not in index, recreating')
download_apod_index(msg=msg)
build_name_list(msg=msg)
get_name(fname=fname, names=names, msg=msg, rerun=False)
else:
if msg >= 1:
print('Error :: name not in index, please recreate')
def regen_index(msg=def_msg, cutoff=None):
download_apod_index(msg=msg)
build_name_list(msg=msg, cutoff=cutoff)
def file_status(date, msg=def_msg, cutoff=None):
"""Status of an APOD Picture."""
downloaded_files = [] # files in main apod download folder
archive_files = [] # files in sub folder
archive_download = [] # files from archive download
videolist = []
for i in os.listdir(archive_folder):
if os.path.isdir(os.path.join(archive_folder,i)):
for j in os.listdir(os.path.join(archive_folder, i)):
j1 = j[2:]
j2 = j1.replace('-','')
archive_files.append(j2)
else:
i1 = i[2:]
i2 = i1.replace('-','')
downloaded_files.append(i2)
for i in os.listdir(video_dir):
videolist.append(i)
if date[:1] == '9' :
tdate = '19{0}' .format(date)
else:
tdate = '20{0}' .format(date)
if cutoff == None:
cutoff = '1995' # apod started 1995 06 16
if tdate <= cutoff:
return 'cut-off'
try:
downloaded_files.index(date)
if msg >= 5:
print('picture has been downloaded')
return 'downloaded' #print('picture from {0} has already been downloaded' .format(pagedate))
except:
pass
try:
archive_files.index(date)
if msg >= 5:
print('picture has been downloaded')
return 'archived' #print('picture from {0} has already been downloaded' .format(pagedate))
except:
pass
try:
archive_download.index(date)
if msg >= 5:
print('picture has been downloaded by archive retrieval')
return 'retrieved'
except:
pass
try:
videolist.index(date)
if msg >= 5:
print('picture is a video')
return 'video file'
except:
if msg >= 5:
print('picture is missing')
return 'missing'
def download_apod_index(msg=def_msg, index=index_file):
"""Downloads the apod index file."""
import urllib.request
try:
response = urllib.request.urlopen('http://antwrp.gsfc.nasa.gov/apod/archivepix.html')
html = response.read()
if msg > 3:
print('downloaded apod index')
check_file(index, create=True, msg=msg)
f = open(index, 'wb')
f.write(html)
f.close()
except:
if msg >= 1:
print('Fatal Error :: index page not found')
sys.exit()
def build_name_list(msg=def_msg, index=index_file, names=namefile, cutoff=None):
"""Builds a name list."""
check_file(names, create=True, msg=msg)
data = []
with open(index, 'r') as f:
for line in f:
if '<a href="ap' in line:
i = line.split(':', 1)
imgdate = i[1][13:19]
imgname = i[1][26:-9]
status = file_status(date=imgdate, msg=msg, cutoff=None)
if imgdate[:1] == '9' :
imgfile = '19{0}-{1}-{2}' .format(imgdate[:2], imgdate[2:4], imgdate[4:])
else:
imgfile = '20{0}-{1}-{2}' .format(imgdate[:2], imgdate[2:4], imgdate[4:])
if msg >= 3:
print('found file : date = {0} : status = {1} : filename = {2}' .format(imgdate, status, imgfile))
data.append('{0},{1},{2},{3} \n' .format(imgfile, imgdate, status, imgname))
if msg >= 4:
print('finished parsing index file')
with open(namefile, 'w') as newf:
for j in data:
newf.writelines(j)
if msg >= 4:
print('written new name list')
##### MACROS #####
def download2(msg=def_msg, test=def_test, apodset=def_apodset, force_apod=def_force_apod, clear_apod=def_clear_apod, archive_apod=def_archive_apod):
"""Downloads and sets APOD picture."""
if clear_apod:
clear_date(msg=msg, test=test)
if force_apod:
if msg >= 3:
print('download forced')
if get_date() != dtoday or force_apod:
download_files(msg=msg, test=test, archive_apod=archive_apod)
else:
if msg >= 2:
print('apod has already been downloaded today')
set_apod(msg=msg, test=test, apodset=apodset) # #set apod picture
def archive_download(msg=def_msg, newindex=False, cutoff=None, test=def_test):
"""Search and download missing pictures from the APOD archive pages"""
if newindex:
regen_index(msg=msg, cutoff=cutoff)
target_dates = []
with open(namefile, 'r') as g:
for line in g:
i = line.split(',')
if i[2] == 'missing':
if file_status(date=i[1], msg=msg) == 'missing':
target_dates.append(i[1])
if msg >= 4:
print('target list built')
target_dates.sort()
for j in target_dates:
if msg >= 4:
print('')
download_files(msg=msg, test=test, day=j, archive_apod=True)
##### OPENBOX MENU #####
def gen_obmenu_standard():
import oblib
oblib.pipe_start()
oblib.item('APOD', 'apod.py --update')
oblib.item('APOD Save', 'apod.py --save')
oblib.item('APOD Force', 'apod.py --force')
oblib.pipe_end()
def obmenu_archive_folders(t='pipe'):
import oblib
years = []
for i in os.listdir(archive_folder):
if os.path.isdir(os.path.join(archive_folder,i)):
years.append(i)
years.sort()
years.reverse()
if t == 'pipe':
oblib.pipe_start()
else:
oblib.menu_start('Apod Archive')
for k in years:
oblib.item('Apod: {0}' .format(k), 'wallpaper.py --change {0}/{1}' .format(archive_folder, k))
if t == 'pipe':
oblib.pipe_end()
else:
oblib.menu_end()
##### TEST FUNCTIONS #####
def parser_options():
print('Options are: {0}' .format(options))
print('Args are : {0}' .format(args))
print('Command is : {0}' .format(options.command))
def meta_info():
if options.meta_source == None:
print('No source specifieed')
else:
print('Script launched from source :: {0}' .format(options.meta_source))
def test_module(msg=def_msg):
pass
#gen_obmenu_arfolders()
#unicode_test()
#apod_archive_download(msg=msg)
#print(check_list(args[0]))
#regen_index(msg=msg)
#print(get_name(fname=None, msg=msg))
#print(len(saveprefix))
##### MAIN FUNCTION #####
def Apod_Main(msg=def_msg):
"""Main functions."""
command = options.command
check_dir(work, create=True, msg=msg)
if options.regen_index :
regen_index(msg=msg, cutoff=options.cutoff)
if command == None:
command = 'pass'
if command == "download":
if msg > 3:
print('Updating APOD')
download2(msg=msg, test=options.test, apodset=options.apodset, force_apod=options.force, clear_apod=options.clear, archive_apod=options.archive)
elif command == "download-only":
if msg > 3:
print('Downloading APOD picture only')
download2(msg=msg, test=options.test, apodset=False, force_apod=options.force, clear_apod=options.clear, archive_apod=False)
elif command == "last":
if msg > 3:
print('Setting last APOD')
set_apod(apodlast, msg=msg, test=options.test, apodset=options.apodset)
elif command == "save-today":
apod_save('today', msg=msg, test=options.test)
elif command == "save":
apod_save('current', msg=msg, test=options.test)
elif command == "set":
if msg > 3:
print('Setting APOD')
set_apod(msg=msg, test=options.test, apodset=options.apodset)
elif command == "restore":
if msg > 3:
print('Restoreing yesterdays APOD picture.')
copy_file(apodlast, apodfile, msg=msg, test=options.test)
set_apod(msg=msg, test=options.test, apodset=options.apodset)
elif command == 'retrieve':
archive_download(msg=msg, newindex=options.newindex, cutoff=options.cutoff)
elif command == 'testmod':
test_module(msg=msg)
elif command == "TestNone":
print('Test mode null op[tion')
elif command == "pass":
if msg >= 4:
print('pass option has been called')
elif not command == None:
if msg >= 2:
print('Warning :: Unrecognised command specified')
#pass
else:
if msg >= 2:
print('Warning :: no commands found, using default option')
set_apod(msg=msg, test=options.test, apodset=options.apodset)
##### SCRIPT STARTUP #####
if __name__ == "__main__":
parser = OptionParser(usage = "usage: %prog [download options] [command]", version="%prog {0}" .format(__version__),
description = "Script to manage APOD wallpapers.")
parser.set_defaults(archive=def_archive_apod, apodset=def_apodset, command=None)
standard = OptionGroup(parser, "Standard Options")
doptions = OptionGroup(parser, "Download Options")
aoptions = OptionGroup(parser, "Archive Options")
metaopt = OptionGroup(parser, "Meta Info Options", "Further datails about the script startup useful for debugging")
standard.add_option("-q", "--quiet",
action="store_true", dest="quiet", default=False,
help="only display warnings and errors")
standard.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False,
help="display all output")
standard.add_option("--debug",
action="store_true", dest="debug", default=False,
help="debug mode: detailed output of commands")
standard.add_option("--really-quiet",
action="store_true", dest="reallyquiet", default=False, help=SUPPRESS_HELP)
#help="only display errors")
standard.add_option("--silent",
action="store_true", dest="silent", default=False, help=SUPPRESS_HELP)
#help="don't display any output")
standard.add_option('-t', "--test",
action="store_true", dest="test", default=False, help=SUPPRESS_HELP)
#help="test mode :: only print output")
standard.add_option("--test-mod",
action="store_const", const="testmod", dest="command", help=SUPPRESS_HELP)
#help="test mode :: use test function module")
standard.add_option("--test-none", "--pass",
action="store_const", const="TestNone", dest="command", help=SUPPRESS_HELP)
#help="test mode :: no command specified")
parser.add_option('-a', '-u', '--update',
action="store_const", const="download", dest="command",
help="Downloads and sets the wallpaper as todays APOD picture")
parser.add_option("--save",
action="store_const", const="save", dest="command",
help="Saves the curent APOD wallpaper")
parser.add_option("--set",
action="store_const", const="set", dest="command",
help="Sets wallpaper as APOD")
parser.add_option('--download-only',
action="store_const", const="download-only", dest="command",
help="Only downloads todays APOD picture")
parser.add_option("--last",
action="store_const", const="last", dest="command",
help="Sets the wallpaper as yesterdays APOD picture")
parser.add_option("--restore",
action="store_const", const="restore", dest="command", help=SUPPRESS_HELP)
#help="Restores yesterdays APOD picture as todays.")
aoptions.add_option("--retrieve", '--populate',
action="store_const", const="retrieve", dest="command",
help="Retrives archive APOD images from the APOD archive")
aoptions.add_option("--regen-index",
action="store_true", dest="regen_index", default=False,
help="Regenerates the APOD index file")
aoptions.add_option("--no-index",
action="store_false", dest="newindex", default=True, help=SUPPRESS_HELP)
#help="Do not build a nex index")
aoptions.add_option("--cut-off",
metavar="Date", dest='cutoff', default=def_cutoff,
help="Cut off date for downloading archive pictures")
# parser.add_option("--get-name",
# metavar="NAME", dest="getname", default=None,
# help="Returns the name of a pictures name")
doptions.add_option("--force",
action="store_true", dest="force", default=def_force_apod,
help="Force the download of todays APOD picture")
doptions.add_option("--clear",
action="store_true", dest="clear", default=def_clear_apod, help=SUPPRESS_HELP)
#help="resets the date of last APOD download.")
doptions.add_option("--archive",
action="store_true", dest="archive",
help="If to archive a picture after download")
doptions.add_option("--no-archive",
action="store_false", dest="archive",
help="If to archive a picture after download")
doptions.add_option("--force-set",
action="store_true", dest="apodset", help=SUPPRESS_HELP)
#help="If to set the wallpaper as APOD.")
doptions.add_option("--no-set",
action="store_false", dest="apodset", help=SUPPRESS_HELP)
#help="Skips setting APOD as wallpaper")
metaopt.add_option("--meta-from",
metavar="Source", dest='meta_source', default=None,
help="Details from where the script was launched from")
parser.add_option_group(doptions)
parser.add_option_group(aoptions)
parser.add_option_group(standard)
#parser.add_option_group(metaopt)
(options, args) = parser.parse_args()
## message level
if options.debug == True:
msg = 5
elif options.verbose == True:
msg = 4
elif options.quiet == True: # warnings
msg = 2
elif options.reallyquiet == True: # errors only
msg = 1
elif options.silent == True: # no output
msg = 0
else:
msg = 3
if options.debug:
parser_options()
meta_info()
LockScript(Apod_Main, msg=msg) -
Problem importing a module and finding it's commands?
Hi,
I have a problem. I'm trying to import the DFSR module and use it's commands in my PS session.
But, I can't get the commands to show.
I've looked in my system32 directory and I can see the DFSR module folder.
But when I run the command to import the module nothing happens, and it's not showing in my Module window in the ISE.
What could be going wrong?
ThanksGet-Module -List DFSR
Where did you save the module to?
Modules should be saved to the Modules folder of the profiles folder.
dir "$(Split-Path $profile.CurrentUserCurrentHost)\Modules"
dir "$(Split-Path $profile.AllUsersCurrentHost)\Modules"
¯\_(ツ)_/¯ -
This is frustrating... trying to import CISCO-ENTITY-SENSOR-MIB
Well, really trying to import CISCO-ENTITY-SENSOR-EXT-MIB in order to process traps from ASA with "snmp-server enable traps entity power-supply-failure" configured. Figures that CISCO-ENTITY-SENSOR-MIB is a prerequisite. After painstakingly loading up the MIB dependencies listed at http://tools.cisco.com/Support/SNMP/do/BrowseMIB.do?local=en&step=2&mibName=CISCO-ENTITY-SENSOR-MIB, it fails at the last juncture with
CISCO-ENTITY-SENSOR-MIB itself:
snmpttconvertmib --in=CISCO-ENTITY-SENSOR-MIB.my --out=/etc/snmp/snmptt.conf.cisco --debug
***** Processing MIB file *****
snmptranslate version: NET-SNMP version: 5.3.1
severity: Normal
File to load is: ./CISCO-ENTITY-SENSOR-MIB.my
File to APPEND TO: /etc/snmp/snmptt.conf.cisco
MIBS environment var: ./CISCO-ENTITY-SENSOR-MIB.my
mib name: CISCO-ENTITY-SENSOR-MIB
Processing MIB: CISCO-ENTITY-SENSOR-MIB
skipping a TRAP-TYPE / NOTIFICATION-TYPE line - probably an import line.
Line: 631
NOTIFICATION-TYPE: entSensorThresholdNotification
Variables: entSensorThresholdValue entSensorValue
Enterprise: entitySensorMIBNotifications
Looking up via snmptranslate: CISCO-ENTITY-SENSOR-MIB::entSensorThresholdNotification
No log handling enabled - turning on stderr logging
Cannot find module (ENTITY-MIB): At line 27 in ./CISCO-ENTITY-SENSOR-MIB.my
Cannot find module (CISCO-TC): At line 29 in ./CISCO-ENTITY-SENSOR-MIB.my
Cannot find module (CISCO-SMI): At line 31 in ./CISCO-ENTITY-SENSOR-MIB.my
Did not find 'entPhysicalIndex' in module #-1 (./CISCO-ENTITY-SENSOR-MIB.my)
Did not find 'EntPhysicalIndexOrZero' in module #-1 (./CISCO-ENTITY-SENSOR-MIB.my)
Did not find 'ciscoMgmt' in module #-1 (./CISCO-ENTITY-SENSOR-MIB.my)
Unlinked OID in CISCO-ENTITY-SENSOR-MIB: ciscoEntitySensorMIB ::= { ciscoMgmt 91 }
Undefined identifier: ciscoMgmt near line 33 of ./CISCO-ENTITY-SENSOR-MIB.my
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBConformance ::= { ciscoEntitySensorMIB 3 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBNotificationPrefix ::= { ciscoEntitySensorMIB 2 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBObjects ::= { ciscoEntitySensorMIB 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBNotifications ::= { entitySensorMIBNotificationPrefix 0 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorValueEntry ::= { entSensorValueTable 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorNotifCtrlGlobalGroup ::= { entitySensorMIBGroups 5 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorValueGroupSup1 ::= { entitySensorMIBGroups 4 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorThresholdNotificationGroup ::= { entitySensorMIBGroups 3 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorThresholdGroup ::= { entitySensorMIBGroups 2 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorValueGroup ::= { entitySensorMIBGroups 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdTable ::= { entSensorThresholds 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorMeasuredEntity ::= { entSensorValueEntry 8 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorValueUpdateRate ::= { entSensorValueEntry 7 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorValueTimeStamp ::= { entSensorValueEntry 6 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorStatus ::= { entSensorValueEntry 5 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorValue ::= { entSensorValueEntry 4 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorPrecision ::= { entSensorValueEntry 3 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorScale ::= { entSensorValueEntry 2 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorType ::= { entSensorValueEntry 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdEntry ::= { entSensorThresholdTable 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThreshNotifGlobalEnable ::= { entSensorGlobalObjects 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: ciscoEntitySensorMIB ::= { ciscoMgmt 91 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorGlobalObjects ::= { entitySensorMIBObjects 3 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholds ::= { entitySensorMIBObjects 2 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorValues ::= { entitySensorMIBObjects 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdNotificationEnable ::= { entSensorThresholdEntry 6 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdEvaluation ::= { entSensorThresholdEntry 5 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdValue ::= { entSensorThresholdEntry 4 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdRelation ::= { entSensorThresholdEntry 3 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdSeverity ::= { entSensorThresholdEntry 2 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdIndex ::= { entSensorThresholdEntry 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorThresholdNotification ::= { entitySensorMIBNotifications 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entSensorValueTable ::= { entSensorValues 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBGroups ::= { entitySensorMIBConformance 2 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBCompliances ::= { entitySensorMIBConformance 1 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBComplianceV04 ::= { entitySensorMIBCompliances 4 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBComplianceV03 ::= { entitySensorMIBCompliances 3 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBComplianceV02 ::= { entitySensorMIBCompliances 2 }
Cannot adopt OID in CISCO-ENTITY-SENSOR-MIB: entitySensorMIBComplianceV01 ::= { entitySensorMIBCompliances 1 }
Unknown object identifier: CISCO-ENTITY-SENSOR-MIB::entSensorThresholdNotification
OID:
Done
Total translations: 1
Successful translations: 0
Failed translations: 1
Those three allegedly missing MIBs are right there in the same directory, and have been imported earlier (though some had no "translation"):
ls
CISCO-ENTITY-SENSOR-EXT-MIB.my CISCO-TC.my RFC-1212.my SNMPv2-CONF.my SNMPv2-TC-V1SMI.my
CISCO-ENTITY-SENSOR-MIB.my ENTITY-MIB.my RFC-1215.my SNMPv2-SMI.my v1
CISCO-SMI.my RFC1155-SMI.my SNMP-FRAMEWORK-MIB.my SNMPv2-TC.my
snmpttconvertmib --in=CISCO-SMI.my --out=/etc/snmp/snmptt.conf.cisco --debug
***** Processing MIB file *****
snmptranslate version: NET-SNMP version: 5.3.1
severity: Normal
File to load is: ./CISCO-SMI.my
File to APPEND TO: /etc/snmp/snmptt.conf.cisco
MIBS environment var: ./CISCO-SMI.my
mib name: CISCO-SMI
Processing MIB: CISCO-SMI
Done
Total translations: 0
Successful translations: 0
Failed translations: 0
snmpttconvertmib --in=CISCO-TC.my --out=/etc/snmp/snmptt.conf.cisco --debug
***** Processing MIB file *****
snmptranslate version: NET-SNMP version: 5.3.1
severity: Normal
File to load is: ./CISCO-TC.my
File to APPEND TO: /etc/snmp/snmptt.conf.cisco
MIBS environment var: ./CISCO-TC.my
mib name: CISCO-TC
Processing MIB: CISCO-TC
Done
Total translations: 0
Successful translations: 0
Failed translations: 0
snmpttconvertmib --in=ENTITY-MIB.my --out=/etc/snmp/snmptt.conf.cisco --debug
***** Processing MIB file *****
snmptranslate version: NET-SNMP version: 5.3.1
severity: Normal
File to load is: ./ENTITY-MIB.my
File to APPEND TO: /etc/snmp/snmptt.conf.cisco
MIBS environment var: ./ENTITY-MIB.my
mib name: ENTITY-MIB
Processing MIB: ENTITY-MIB
skipping a TRAP-TYPE / NOTIFICATION-TYPE line - probably an import line.
Line: 1142
NOTIFICATION-TYPE: entConfigChange
Enterprise: entityMIBTrapPrefix
Looking up via snmptranslate: ENTITY-MIB::entConfigChange
OID: .1.3.6.1.2.1.47.2.0.1
Done
Total translations: 1
Successful translations: 1
Failed translations: 0
What am I missing?I've successfully tried to stay clear of this type of thing as much as I could so my response might be silly.
But one of the things I recall was that a 'somemib.my' file needed 'thatothermib', that was actually there in the directory as 'thatothermib.my', just like I downloaded it, but the mibcompiler was smart enough to look for 'thatothermib.mib'.
Not sure if is was referenced in the other mibfile with a specific extension of if it was the compiler trying to stop me.
Never understood how they managed to make something so simple so complicated.
Cheers,
Michel -
Trying to import Adroid MP4 video to CS4
(Originally posted on the CS5 form - was redirected to this one))
I took some video on my Andriod phone at 1280X720. (Samsung Epic)
I try to import the resuling MP4 files it into CS4. Although it imports, it's very jumpy with poor audio sync. I can render the clip, but the final clip is till very jumpy
I bought a conversion program "Super. by eRighSoft' which provides an unlimited number of setting to convert the various specs of the file (sampling trate, video scale, video package etc...) and tried several setting. But still no luck.
Anyone figure out how to get the files to import correctly into CS4 from the Android Epic?
Thanks,
JohnI ran the GSpot program.
When I looked at all Codec and Filters, there seemed to be a bunch of red line items on all the Main Concept files.
For instance, I received the following.
- ** Problem ** ** File Missing:
"C:\Program Files\Adobe\Adobe Premiere Pro CS4\ad2dsh264.ax"
- - Type DSH
- - Function Decoder
DSH 4CC Video
DSH Friendly Name "MainConcept (Adobe2) H.264/AVC Decoder"
DSH DirectShow CLSID {FF890B41-A4C5-4B19-87CF-65D86EC12F1C}
REG Driver File "C:\Program Files\Adobe\Adobe Premiere Pro CS4\ad2dsh264.ax"
REG Merit 0x00600000
The file is in fact there. Also tried to re-register it, and it failed. "Unable to load module"
I recently upgraded to Win7 and just reinstalled Premier CS4 last week.
Maybe that's where my issues are coming from?
Here's the info on the file I'm trying to import.
Container:
3gp4: 3GPP Media (.3GP) Release 4
- 3gp6: 3GPP Media (.3GP) Release 6 Basic Profile
Recommended Display Size: 1280 x 720
Codec: avc1
Name: H.264/MPEG-4 AVC
Status: Codec Status Undetermined
Len: 0:46.336
Frms: 1,386
Kbps 12021 Qf: 0.430
Pics/s 30.303 Frames/s 30.303
Pic: 1280X770
sar: 1.778 (16:9)
der: 1.788(16:9)
Codec - Audio mp4a: MPEG-4 AAC LC
16000Hz 62 kb/s , mono (1/0)
When I tried the 'Proposed Codec Solutions And Tests' (Option 1's), I receive the error :
"GSpot is not yet capable of attempting to render this video type. -
Problems when trying to import metadata from SQL server using OWB
Hi,
We are using Oracle 11.2 EE on AIX and OWB: 11.2. We are in the process testing Oracle Transparent gateway for SQL Server and have installed and configured it on a standalone windows server. We and have run the ORACLE_HOME\dg4msql\admin\dg4msql_cvw.sql on SQL Server side, in order to query the SQL-Server data dictionary. We have created a DB-link and can pull data correctly without any problems. When trying to import metadata in OWB Client on win xp, we have created a non-oracle SQL Server Module and are able to connect and start the import, but the displayed table names look strange and can not be imported. In front of every letter there is a square box, so instead of ADDRESS (the address table in the source system) , it reads "squarebox"A"squarebox"D"squarebox"D"squarebox"R"squarebox"E"squarebox"S"squarebox"S and subsequently the import fails with :API0413: Illegal name [<tablename>] Name with preceding and trailing spaces is not allowed.
The gateway have been configured with the following parameters:
HS_FDS_CONNECT_INFO=<connect string>
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
HS_LANGUAGE=AMERICAN_AMERICA.WE8MSWIN1252
Any ideas ?
This topic has been posted in the Heterogenious Forum as well, but as the problem is within OWB, I also post it here.
Thanks in advance!
Henrik
Edited by: he**** on Nov 15, 2011 1:29 PMHenrik,
I've found other problems where OWB adds a space between all characters returned from SQL*Server which is what is happening in your case, although it is being displayed as a square box.
In one of these cases the problem was fixed by using the 11.2.0.2 OWB so would it be possible for you to try with that version ?
Also, as the problem is not with the gateway itself as you can select successfully using a database link then it would be better to follow up in the OWB forum -
Forum: Warehouse Builder
Warehouse Builder
as they will be able to help with the OWB side of the problem.
Regards,
Mike -
Can't import grouppolicy module on a DC, with the GMPC installed
Hi all,
I've got a Windows Server 2008 DC which has the GPMC installed already, but I can't import the grouppolicy module.
import-module : The specified module 'grouppolicy' was not loaded because no valid module file was found in any module
directory.
I've tried removing, restarting and readding the GMPC from the Add Features section of server manager, but no joy.
I tried to copy the module folder from $pshome/modules from another machine, but this didn't work either - I then got told that the assembly can't be found. I then looked in the assemblies folder, and there's a few related to grouppolicy, but not the Micrsoft.GroupPolicy.Management
one it's moaning about. I can't copy these from machine to machine either.
If it makes any difference, we have three DCs for this domain, and it's doing the same on both of the virtual ones (the last, physical machine is due to be virtualised soon, so no point in making it work on there). We have two other domains that I've tried
to do this one, and they've both worked fine, although they're running 2008 R2 instead...
Thanks for any help!
JoeHi Joe,
The GPMC cmdlets can't run on WS2008, they require a minimum of WS2008R2:
http://technet.microsoft.com/en-us/library/ee461027.aspx
Don't retire TechNet! -
(Don't give up yet - 12,830+ strong and growing) -
Geting an error trying to import a data file into OWB repository
Hi,
We're using OWB 11.1.0.7.0
I'm trying to import a new data file and I'm getting an error.
When I go to The Project/Files/ I right click on the module I want to add the files to,
I get a 'Wizard' titled 'Welcome to the Import Metadata Wizard'.
I click next.
I get the 'Filter Information' screen that asks if I want to select 'All Data Files' or a specific file.
I pick 'All Data Files' and click 'next'.
I get the 'Object Selection' screen that has a left and right panel. The left side is titled 'Available' and the right side is titled Selected.
The 'Available' panel had the directory in Linux (/etl/datafeeds/dev) where our data files are stored with a plus sign next to it.
When I click the plus sign, I get an error message that says:
API2836: Directory
/etl/datafeeds/dev does not exist.Has anyone seen this? What is the work around? Is it a bug? How do I import a data file into OWB if this isn't the way to do it?
Thanks,Hi, is there any obligation to use import wizard?
can you use right click and import view/table?
Ugur MIHCI
www.ifslibrary.com
Maybe you are looking for
-
How can i save the acr changes i make to jpegs (not as sidecar xmps)?
Hi Guys! I have been a full-time pro photog for 16 years and yes, yes, I always shoot in raw. Except on my cameraphone. I am on a pc. We have hundreds of pics that my family took on cameraphones on a recent cruise (when we didn't feel like lug
-
I updated my iPhone 4 to iOS 5 immediately the battery went bananas. I was excited about Siri and a better camera so I purchased the iPhone 4S, but I have to say I am dissapointed, I am seriously considering going back to iOS 4. When can we expect a
-
JSF render -Third party component
Hai All I am having doubt regarding JSF Third party component like Jmaki ,MyFaces or something like that . How the third party component match with JSF life cycle even though there is no java classes for managing and rendering the Third party compone
-
BC4J cleaning up after session timeout
Hi Can anyone advise me on how to cleanup a database table via BC4J when a session times out. When someone logs into my application I enter an audit trail into a table. When they logout or when the session times out I want to add a logout time. I hav
-
One-to-one two sided relationship causing two outer joins.
We have a fairly simple one-to-one relationship between two objects A and B. A maps to table A, B maps to table B. A holds a foreign key to B. Both classes hold a reference to each other. What we are trying to achieve is to load both A and B with a s