I'm currently working on a script that creates a tray icon that allows the user to adjust screen brightness through menu options. The source code, written in python 3.6.8, can be found as a paste HERE. There seems to be an error message coming up when trying to select one of the brightness options, seen HERE. I did some reading and found that the error I'm getting (0x8004100c) refers to a feature or operation not being supported. Are there any workarounds available for this?
Thank you in advance.
code: https://pastebin.com/sLbyE9yb
error: https://pastebin.com/Xs7wHk73
WMI error reference: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants
gist: https://gist.github.com/imri0t/12e768e3d7e08734b85ae532d56090e1
(also if anyone can let me know if there's a way to keep the script from dying after an action is made it would be appreciated)
modules needed: pip install infi.systray / pip install wmi
code snip that I believe produces the error:
from infi.systray import SysTrayIcon
import wmi
def brightness_50(systray):
'''brightness: 50%'''
b = 50
c = wmi.WMI(namespace='root\\wmi')
br = c.WmiMonitorBrightnessMethods()[0]
br.WmiSetBrightness(3, b) #b will be a precentage / 100
menu = (("brightness: 100%", None, brightness_50))
systray = SysTrayIcon("icon.ico", "brightness", menu)
systray.start()
Related
If I run
python -m manimlib scene.py ket_bra
My scene renders fine into the interactive viewer, but I don't get any output file, the terminal prints the following
ManimGL v1.6.1
[13:55:48] INFO Using the default configuration file, which you can modify in `c:\users\miika\manim\manimlib\default_config.yml` config.py:323
INFO If you want to create a local configuration file, you can create a file named `custom_config.yml`, or run `manimgl --config` config.py:324
WARNING You may be using Windows platform and have not specified the path of `temporary_storage`, which may cause OSError. So it is recommended to specify the `temporary_storage` in the config file config.py:290
(.yml)
(process:3548): GLib-GIO-WARNING **: 13:55:49.613: Unexpectedly, UWP app `Clipchamp.Clipchamp_2.3.0.0_neutral__yxz26nhyzhsrt' (AUMId `Clipchamp.Clipchamp_yxz26nhyzhsrt!App') supports 46 extensions but has no verbs
If I add the parameter -p to the command then the interactive window remains blank and doesn't render the scene and in no case do I get an output file which is what I'm looking for and the terminal output is the same as before. Also if it's of note the background is grey, even tho it appears to be black in all samples that I can find. I have absolutely no idea what's going on as I can't find anybody else with a similar issue. I'm using windows 10 and v1.6.1 of 3b1b manim. The scene in this case is as follows (though this issue appears regardless of what the scene is)
from manimlib import *
class ket_bra(Scene):
def construct(self):
ket_q0 = Tex(r"|q_0\rangle")
ket_0 = Tex(r"|0\rangle")
ket_1 = Tex(r"|1\rangle")
ket_0_v2 = Tex(r"|0\rangle")
ket_1_v2 = Tex(r"|1\rangle")
ket_0_v3 = Tex(r"""|0\rangle=\begin{pmatrix}
1\\
0
\end{pmatrix}""")
ket_1_v3 = Tex(r"""|1\rangle=\begin{pmatrix}
0\\
1
\end{pmatrix}""")
bra_kets = VGroup(ket_q0, ket_0, ket_1).arrange(RIGHT, buff=1)
v_bra_kets = VGroup(ket_0_v2, ket_1_v2).arrange(RIGHT, buff=1.5)
bra_kets_def = VGroup(ket_0_v3, ket_1_v3).arrange(RIGHT, buff=1.5)
self.play(Write(ket_q0), Write(ket_0), Write(ket_1))
self.wait(0.5)
self.play(FadeOut(ket_q0))
self.play(Transform(ket_0, ket_0_v2), Transform(ket_1, ket_1_v2))
self.wait(1)
self.play(Transform(ket_0, ket_0_v3), Transform(ket_1, ket_1_v3))
Well I fixed the problem, without fixing the problem, I just switched to the community edition of manim and it works exactly as intended, so if you encounter the same problem and you're using 3b1b manim version, I reccomend just switching to the community version of manim, they are mostly functionally equivalent, but the community edition appears to be less buggy at least for me. Here's a super easy installation guide for it https://docs.manim.community/en/stable/installation/windows.html
However, I won't mark this as the best answer, because I didn't really solve the problem, and I still get the following warning and have no idea what it is. However, it appears to not affect functionality so it's fine, lol.
Windows Solution
Create TempLatex directory in C drive
Find manimlib/default_config.yml in the manim (manimgl version) directory and open it with a text editor
Modify line 18: before: temporary_storage: "" after: temporary_storage: "C:/TempLatex "
Save
From:
https://github.com/3b1b/manim/issues/1661#issuecomment-996575974
I am trying to change the user of a print job in the queue, as I want to create it on a service account but send the job to another users follow-me printing queue. I'm using the win32 module in python. Here is an example of my code:
from win32 import win32print
JOB_INFO_LEVEL = 2
pclExample = open("sample.pcl")
printer_name = win32print.GetDefaultPrinter()
hPrinter = win32print.OpenPrinter(printer_name)
try:
jobID = win32print.StartDocPrinter(hPrinter, 1, ("PCL Data test", None, "RAW"))
# Here we try to change the user by extracting the job and then setting it again
jobInfoDict = win32print.GetJob(hPrinter, jobID , JOB_INFO_LEVEL )
jobInfoDict["pUserName"] = "exampleUser"
win32print.SetJob(hPrinter, jobID , JOB_INFO_LEVEL , jobInfoDict , win32print.JOB_CONTROL_RESUME )
try:
win32print.StartPagePrinter(hPrinter)
win32print.WritePrinter(hPrinter, pclExample)
win32print.EndPagePrinter(hPrinter)
finally:
win32print.EndDocPrinter(hPrinter)
finally:
win32print.ClosePrinter(hPrinter)
The problem is I get an error at the win32print.SetJob() line. If JOB_INFO_LEVEL is set to 1, then I get the following error:
(1804, 'SetJob', 'The specified datatype is invalid.')
This is a known bug to do with how the C++ works in the background (Issue here).
If JOB_INFO_LEVEL is set to 2, then I get the following error:
(1798, 'SetJob', 'The print processor is unknown.')
However, this is the processor that came from win32print.GetJob(). Without trying to change the user this prints fine, so I'm not sure what is wrong.
Any help would be hugely appreciated! :)
EDIT:
Using Python 3.8.5 and Pywin32 303
At the beginning I thought it was a misunderstanding (I was also a bit skeptical about the bug report), mainly because of the following paragraph (which apparently seems to be wrong) from [MS.Docs]: SetJob function (emphasis is mine):
The following members of a JOB_INFO_1, JOB_INFO_2, or JOB_INFO_4 structure are ignored on a call to SetJob: JobId, pPrinterName, pMachineName, pUserName, pDrivername, Size, Submitted, Time, and TotalPages.
But I did some tests and ran into the problem. The problem is as described in the bug: filling JOB_INFO_* string members (which are LPTSTRs) with char* data.
Submitted [GitHub]: mhammond/pywin32 - Fix: win32print.SetJob sending ANSI to UNICODE API (and none of the 2 errors pops up). It was merged to main on 220331.
When testing the fix, I was able to change various properties of an existing job, I was amazed that it didn't have to be valid data (like below), I'm a bit curious to see what would happen when the job would be executed (as now I don't have a connection to a printer):
Change pUserName to str(random.randint(0, 10000)) to make sure it changes on each script run (PrintScreens taken separately and assembled in Paint):
Ways to go further:
Wait for a new PyWin32 version (containing this fix) to be released. This is the recommended approach, but it will also take more time (and it's unclear when it will happen)
Get the sources, either:
from main
from b303 (last stable branch), and apply the (above) patch(1)
build the module (.pyd) and copy it in the PyWin32's site-packages directory on your Python installation(s). Faster, but it requires some deeper knowledge, and maintenance might become a nightmare
Footnotes
#1: Check [SO]: Run / Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (#CristiFati's answer) (Patching UTRunner section) for how to apply patches (on Win).
I was working on something an I this is actually my first time so things are not that clear for me yet, I ran this code :
pip install nipype
from nipype import Node, Workflow
from nipype.interfaces.fsl import SliceTimer, MCFLIRT, Smooth
slicetimer = Node(SliceTimer(index_dir=False,
interleaved=True,
time_repetition=2.5),
name="slicetimer")
mcflirt = Node(MCFLIRT(mean_vol=True,
save_plots=True),
name="mcflirt")
smooth = Node(Smooth(fwhm=4), name="smooth")
preproc01 = Workflow(name='preproc01', base_dir="dir_path")
preproc01.connect([(slicetimer, mcflirt, [('slice_time_corrected_file', 'in_file')]),
(mcflirt, smooth, [('out_file', 'in_file')])])
slicetimer.inputs.in_file = "file_path"
preproc01.run('MultiProc')
This is the error shown when I run the last line of code :
"Could not import plugin module: nipype.pipeline.plugins"
There is one more problem :
When I try to run this code :
preproc01.write_graph(graph2use='orig')
This is the error message shown :
'No command "dot" found on host. Please check that the corresponding package is installed.'
please if anyone knows the solution help me out.
BTW I an doing this from a video series, here is the link :https://www.youtube.com/watch?v=4FVGn8vodkc&t=4414s
Nipype showcase section.
I am using Python 3.8.3 and XLWings 0.19.5. I am trying to write a try...catch while running excel equations directly in a workbook, but equations with certain errors are causing the application to hang. I think this is due to a message box popping up.
import xlwings as xw
appExcel = xw.apps.add()
appExcel.display_alerts = False
appExcel.screen_updating = False
wbEquation = xw.Book()
wbEquation.sheets.add(name='Calculate')
wsEquation = wbEquation.sheets['Calculate']
badFormula = "=A1+(A2+A3"
try:
wsEquation.range('B1').formula = badFormula
except Exception:
appExcel.quit()
raise Exception("There was an error when running the equation.")
With display_alerts=False I am not sure why it is getting hung on the wsEquation.range('B1').formula = badFormula line, I believe due to a There is a problem with a formula error. On the older version of XLWings 0.10.0 I was running it does not get hung up and moves past the error message when I try and execute this equation.
*Edit: So I tested to see which version exactly breaks it and I was able to keep it working through 0.11.5. Upgrading to 0.11.6 broke it. I do not see anything in the release notes between the two versions suggesting why that would be.
So for right now I am fixing by rolling back to 0.11.5:
pip install "XLWings==0.11.5"
I have put in a bug report: link and it was marked as a bug so I think they will be working on it.
Despite following the Maya command documentation shown here:
import maya.cmds as cmds
cmds.bindSkin( unbind=True ) # While my object is selected.
or
cmds.bindSkin( 'mySelectedObj', unbind=True ) # Specifying which object to unbind
results in:
Error: RuntimeError: file line 1: No skin partition
found in scene.
I'm also getting the same error in MEL. But the script editor's history shows a doDetachSkin command - and searching on it just keeps leading me back to the bind skin command.
How should I correctly write this command when following the example on the documentation is giving me the error message?
P.S.: My selection is a geo mesh that is skinned to a few joints.
Did you tried with selection ?
mySelectedObj = cmds.ls(sl=True) or []
if mySelectedObj:
cmds.bindSkin(mySelectedObj[0], unbind=True )
import maya.mel as mel
skinC = mel.eval('doDetachSkin "2" { "1","1" }')
Decided to work around the issue instead by just invoking the mel command that I see in the script editor history. Not ideal but serves my purposes for now.
If anyone knows of a better way or can clue in why following the documentation isn't working, please feel free to chime in.
If Unbind Skin Python command doesn't work:
import maya.cmds as cmds
cmds.bindSkin( unbind=True, bp=False )
Try its great old MEL equivalent:
DetachSkin;
It looks like bindSkin can only delete the jointCluster, and you can try skinCluster.
import pymel.core as pm
pm.skinCluster(objname, edit=True, unbind=True)enter code here