w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Raspberry PI: PHP call python script with sudo
Mm, i have try with this two simple example: /Scripts/test.py #!/usr/bin/env python print (str('hello world')) /var/www/test.php <?php echo shell_exec('/Scripts/test.py'); ?> via a browser, show me "hello world" Perhaps try this: chmod a+x your_py_file.py Hope that help..

Categories : Nginx

C++ Creating a Screen Saver for Windows
It's more than just renaming the file. At the bare minimum you must support correct behavior in response to the following command line parameters (taken from Microsoft): ScreenSaver - Show the Settings dialog box. ScreenSaver /c - Show the Settings dialog box, modal to the foreground window. ScreenSaver /p <HWND> - Preview Screen Saver as child of window <HWND>. ScreenSaver /s - Run the Screen Saver. If multiple instances of your executable are being started and run as a full screen screen saver (the screen saver should only actually run if /s is specified), that may be the cause of your performance issues. You should verify that in e.g. Task Manager. Hope that helps.

Categories : C++

Need to Create Screen Saver from Scratch
Since it's a flash app you may be able to run it through a browser/as a web page. See this post for additional info: webpage as a screensaver windows 7 and XP?

Categories : Visual Studio 2010

Running Python script causes Raspberry Pi to lose power
I tried your script. It locks up the rpi at this line GPIO.setup(6,GPIO.IN,pull_up_down=GPIO.PUD_DOWN) GPIO06 isn't one of the pins on the GPIO port. You'd have look at the schematic to see what it's connected to. Looks like it's LAN_RUN. What are you trying to do with it? From elinux.org GPIO06 is LAN_RUN and is available on pad 12 of the footprint for IC3 on the Model A. On Model B, it is in use for the Ethernet function. So unless you have a model A, you shouldn't be using GPIO06

Categories : Python

Twisted Python script on Raspberry Pi (Debian) to communicate with Arduino via USB
Judging from this: http://twistedmatrix.com/trac/browser/tags/releases/twisted-12.3.0/twisted/internet/_win32serialport.py#L84 you should be looking at dataReceived(self,...) method of your Protocol subclass Thus: class USBclient(Protocol): def connectionMade(self): global serServ serServ = self print 'Arduino device: ', serServ, ' is connected.' def cmdReceived(self, cmd): serServ.transport.write(cmd) print cmd, ' - sent to Arduino.' pass def dataReceived(self,data): print 'USBclient.dataReceived called with:' print str(data) try this to see if it works.

Categories : Python

How to show a preview of screen saver inside WPF window
You need to use Windows.Forms interop, because screen savers expect windows handles (HWND) and in WPF, only top-level windows have them. MainWindow.xaml <Window x:Class="So18547663WpfScreenSaverPreview.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" Title="Screen Saver Preview" Height="350" Width="525" Loaded="MainWindow_OnLoaded" Closed="MainWindow_OnClosed" SizeToContent="WidthAndHeight"> <StackPanel Orientation="Vertical" Margin="8"> <TextBlock Text="Preview"/> <WindowsFormsHost x:Name="host" Width="320" Height="240"> <

Categories : C#

screen saver application when deployed in C:WindowsSystem32 throws exception
The problem is that the screensaver was compiled for 32bit cpu. Only 64bit exes are allowed in the %WINDIR%System32 folder on a 64bit OS. Which in fact, i was using Windows7 64bit. The correct place to put 32bit screensavers is in %WINDIR%SysWOW64 or compile using 'AnyCPU' option in Visual Studio then you can install into the %WINDIR%System32 for all.

Categories : Wcf

executing a script after the user has logged in, on Raspberry pi
Raspberry PI runs a Debian OS. A related discussion on how to run python scripts at startup can be found here If you want to run the script whenever a new terminal is launched, you need to update your .bash_profile, .profile, .bashrc files. More on this here

Categories : Misc

NFC tag reading in python on raspberry pi
There are lots of links on google wherein you can find information on data format used in NFC. Some of them are http://learn.adafruit.com/adafruit-pn532-rfid-nfc/ndef http://developer.nokia.com/Community/Wiki/Understanding_NFC_Data_Exchange_Format_(NDEF)_messages

Categories : Python

Raspberry Pi Python PWM RuntimeError: No access to /dev/mem
The problem is with the code above is that I forgot to set RED to at output before trying to use it. The error message did not help resolve this problem. Next time, I need to remember to setup PWM pins as outputs before trying to use them.

Categories : Python

Using Python smbus on a Raspberry Pi - confused with syntax
I'm absolutly not sure this is the problem, but according to the specs p22: MMA7660FC is read using it’s internally stored register address as address pointer, the same way the stored register address is used as address pointer for a write. The pointer generally auto-increments after each data byte is read using the same rules as for a write (Table 5). Thus, a read is initiated by first configuring the device’s register address by performing a write (Figure 11) followed by a repeated start. The master can now read 'n' consecutive bytes from it, with the first data byte being read from the register addressed by the initialized register address. As far as I understand, to "read" from a register, you have to start by writing the register address, and then blindly read a byte

Categories : Python

Invoke python script from another python script and set execution directory of the executed script
You could use cwd parameter, to run scriptB in its directory: import os from subprocess import check_call check_call([scriptB], cwd=os.path.dirname(scriptB))

Categories : Python

No video file created by OpenCV 2.3.1 with Python on Raspberry Pi
I eventually went through and tried all of the fourcc codecs and none worked. Same with the mpeg2 codec. I ended up using avconv to create and capture the video with this line: import os os.system("avconv -f video4linux2 -input_format mjpeg -i /dev/video0 output.avi") os.system() is used to run a terminal command. OpenCV can still be used to process the video files at a later time. Hope this helps someone.

Categories : Opencv

Raspberry pi will not send serial data to an arduino using either minicom or python
You need to read up on the difference between arduino and raspPI 'serial' pins - in short, their voltage levels are quite different and require a conversion cable between the two of them to adjust these levels.

Categories : Python

How can I make a connection between Raspberry Pi and a Bluegiga WT11i Bluetooth Module using Python?
Got it!! pi@raspberrypi ~ $ aptitude install bluetooth pi@raspberrypi ~ $ hcitool dev Devices: hci0 00:07:80:54:CA:E2 pi@raspberrypi ~ $ hcitool scan Scanning ... 00:07:80:54:CA:E2 BGWT11i pi@raspberrypi ~ $ bluez-simple-agent hci0 00:07:80:54:CA:E2 Enter PIN Code: 1234 Now I can connect ... pi@raspberrypi ~ $ python rfcomm-client.py 00:07:80:54:CA:E2

Categories : Python

appending to head based on screen width
You can create a script element and set its src property then append it to the head of the document var script = document.createElement('script'); script.src = 'js.js'; document.head.appendChild(script) if wants to support IE < 9 then instead of document.head use document.getElementsByTagName('head')[0]

Categories : Javascript

Porting Python Raspberry Pi application to Twisted - how to handle background threads that poll the hardware
You can use LoopingCall (howto) to schedule a repeated function call on a certain interval. This probably replaces your polling threads entirely.

Categories : Python

Python having trouble accessing usb microphone using Gstreamer to perform speech recognition with Pocketsphinx on a Raspberry Pi
So I finally got this guy working. Couple key things I needed to realize: 1. Even if you're using Pulseaudio on your Raspberry Pi, as long as Alsa is still installed you're still able to use it. ( This might seem like a no brainer to others, but I honestly didn't realize I could still use both of these at the same time ) Hint via (syb0rg). 2. When it comes to sending large amounts of raw audio data ( .wav format in my case ) to Pocketsphinx via Gstreamer, (queues) are your friend. After messing around with gst-launch-0.10 on the command line for a while I came across something that actually worked: gst-launch-0.10 alsasrc device=hw:1 ! queue ! audioconvert ! audioresample ! queue ! vader name=vader auto-threshold=true ! pocketsphinx lm=/home/pi/dev/scarlettPi/config/speech/lm/scarlett

Categories : Python

how to pass variable from python to shell script when shell script is getting called inside python script
You can: Step through the list, and then call mail.sh once for each file. This is the most reliable way. Convert the items in the list to a space delimited string, and then pass it in to mail.sh (assuming mail.sh is setup correctly, it should accept multiple arguments). What you cannot do is pass ['a.txt','b.txt','c.txt'] wholesale to the script.

Categories : Python

On Mac, how to create a drag & drop app for a python script where the script name rather than Python shows in the MenuBar (etc.)?
I have an answer to my question, but I am hoping that someone can come up with something less complex. The solution I came up with was a Python script to create an AppleScript (ugh!), compile it into a bundle and then modify the bundle to change the allowed file extension(s), the icon and so on. I did not find a way to get drag-and-drop working when starting a wxpython script, without an AppleScript (or using py2app) and I could not get the AppleScript to work in a bundle I created, I had to use osacompile to create the bundle for me. I like better the approach here or here, where one creates the plist file "by hand" rather than than modify an externally created one as I do here, but the script below does do the job. #!/usr/bin/env python '''This script creates an AppleScript app to

Categories : Python

How can I modify a screensaver (.saver)?
The modification of the source code isn't very hard. The colors are computed on the fly, so an asset can't be modified to change the color. In line 226 of MatrixStrip.m change the 1 before the left bracket to a 0. In Line 228 Change the 0 to a 1. The column below the V in the code. .... V 226: colorArray[16*i + 4*c + 0] = (cellState[i] == 0) ? 0.0 : g; 227: // Cells which are very bright are slightly whitened 228: colorArray[16*i + 4*c + 1] = ((g > 0.7) && (cellState[i] != 0)) ? (g - 0.6) : 0.0; Make the same change to lines 253 and 255. You are putting the numbers in column column 34 in the inner loops in order. In the original code, reading down column 34 the numbers a 1, 0, 2, 3. This has to be done in both of the inner loops on the 4 l

Categories : Xcode

Jenkins runs imported python script before main python script
The child process flushes its output buffers on exit but the prints from the parent are still in the parent's buffer. The solution is to flush the parent buffers before running the child: print("Starting script...") sys.stdout.flush() build.run()

Categories : Python

MacOsX: ScreenSaver -- how to get the path to .saver bundle
You'd want to use NSString* imageName = [[NSBundle bundleForClass:[self class]] pathForResource:@"DefaultImage" ofType:@"jpg"]; assuming that this code is in a class belonging to the bundle.

Categories : Osx

Duplicate HTML - page space saver
Yes, you could use var new_div = $('#div').clone(); And then use append/prepend/insertBefore etc to insert it in the DOM. Make sure you change the id of the clone or there might be complications with DOM manipulations after the clone is inserted.

Categories : Jquery

Mac OS X Energy Saver mode does not open or function
I've found the answer. The solution is to go to /Applications in the Finder, right click System Preferences, select Get Info, and check the box that reads Open in 32 bit mode.

Categories : Osx

how to call a python script inside another python script where both in the same directory?
In script1.py place this: def main(): do something if __name__ == "__main__": main() In script2.py: import script1 if condition: script1.main()

Categories : Python

Dropbox drop-in saver local host file error
No, it is not possible to upload a local hosted file to Dropbox via drop-in saver, drop-in saver just let you download a file to your Dropbox quota so it need an public accessible URL to download that file on Dropbox servers while localhost URL is only accessible for you.

Categories : Javascript

Dropbox Drop-In Saver not working: Received non-200 response status 503 from server
Double-check your URLs and how they're being redirected. For example, the first URL on your page, http://phototrip.fnovy.com/uploads/images/2013-08-12_Test_File.png, is responding with a 302 redirect to http://phototrip.fnovy.comuploads/images/2013-08-12_Test_File.png, which is, naturally, not resolving. :-) I believe that the 503 is a somewhat misleading interpretation of the real problem, which is that the domain doesn't resolve. I'll update this answer if I learn more about that. EDIT Confirmed that you see a 503 when the domain doesn't exist. We may be able to give a clearer error message for that, and I also hope we can give the URL in the error message so it's easier to see which URL is causing the problem. Thanks for pointing this out.

Categories : Javascript

sys module giving different output when running Python script through IDLE and by double-clicking the script
print os.path.dirname(sys.executable) is what you should use. When you click it it is probably running through python.exe so you are removing the extra char from the w.

Categories : Python

Cron not running Python script is script not in home folder
cron is running crontab(5) entries from the home directory of the user. You need to change appropriately the directory i.e. to call the chdir(2) syscall (either thru the cd shell builtin, or inside your python script using os.chdir). You should query the current directory (using getcwd(3), or the pwd command, or the os.getcwd in Python) in your script. Also check your PATH if running commands.

Categories : Python

How do scan a script for return values from a upper script in python?
Don't invoke a Python script from a Python script by using system, which spawns a whole other interpreter. Just import it. Like this: import ToBuildOrNot needsBuild = ToBuildOrNot.run() # or whatever you call your top-level function Since ToBuildOrNot.py is a script now, make sure the "main" function is protected so it doesn't execute automatically on import. Most people do it this way in Python: What does <if __name__=="__main__":> do?

Categories : Python

Redirect output of a .bat file run by a python script to GUI, and making that script into EXE
You could use the subprocess module to call your script Example calling the 'ls' command on Linux: >>> from subprocess import call >>> call(['ls', '-l']) total 0 -rw-rw-r-- 1 user group 0 Jun 17 18:37 file1 -rw-rw-r-- 1 user group 0 Jun 17 18:37 file2 -rw-rw-r-- 1 user group 0 Jun 17 18:37 file3 0

Categories : Python

dump files from bash script in different directory from where python script ran it
You should change directory within the same command: cmd = "/path/to/executable/executable" outputdir = "/path/to/output/" subprocess.call("cd {} && {}".format(outputdir, cmd), shell=True)

Categories : Python

error with global name when running a script from another script - python
This is a pretty interesting problem. First a quick workaround, you can provide dictionaries to use as the local and global namespace when calling execfile(), using an empty dictionary for globals works fine: # test_fun1.py a = 1 def test1(): print a execfile('test_fun2.py', {}) test1() Alternatively, if you want the code to execute within the global scope of your module you can use globals() instead of {}. Now on to why this isn't working... from the documentation on execfile(): If both dictionaries are omitted, the expression is executed in the environment where execfile() is called. Here "both dictionaries" is referring to the optional globals and locals arguments to execfile(). In this case "the environment where execfile() is called" is the local scope of the fun

Categories : Python

How run a Python script from another script and get resulting global dict?
Importing a module executes the code at the top level, and that module's "global" namespace gets imported as the name of the module james@bodacious:~$cat test.py def func(): pass myname = "michael caine" print "hello, %s" % myname james@bodacious:~$python Python 2.7.5 (default, Jul 12 2013, 18:42:21) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import test hello, michael caine >>> dir(test) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'func', 'myname'] >>> if the code you want to be run is at the top level of the file, just importing the module will execute the code and give you access to its "global" namespace all in one convenient package.

Categories : Python

ImportError when calling python script via a shell script
I had a similar problem. It turned out that in my bash script I was running the Python script with a different version of Python than I was on the command line (my env was set up with virtualenv on Python 2.7 but I was calling the script with Python3 from the bash script). There is nothing in your snippets indicating this is the case but it is worth checking to make sure that the Python versions match up.

Categories : Python

before waiting a response from other script, echo something on screen in php
It appears you're trying to do something AJAX was built for. So please check out http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/

Categories : PHP

Run "screen -S name ./script" command on @reboot using crontab
You want to add the following options to the 'screen' commands (e.g. before -S): -d -m From the manpage: -d -m Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.

Categories : Linux

White Screen error When running script
Try ini_set('display_errors', 'On'); Basically since the latest release of PHP you can define error visibility per each level, but this line should do it. Let me know if it helps, if not I might rewrite your code using PDO and try - catch blocks, this way you will be able to raise an exception, and generally your code will be more secure. http://php.net/manual/en/book.pdo.php

Categories : PHP

Load script if screen wide enough AND if parent div is in view
I think you'll have to find out how far the user has scrolled to be able to identity if the div is visible. So what you could do is (wrote this from mobile and didn't check your code for syntax errors): var loaded = false; var proximity = 0; if (loaded == false){ $(window).scroll(function () { var scrollBottom = $(".tweet").offset().top - $(window).scrollTop(); var windowWidth = $(window).width(); if (scrollBottom <= proximity && windowWidth > 1250 && loaded == false) { $(".tweet").load("/ajax/"); loaded = true; } }); } Hope that helps you.

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.