How to initiate Aldebaran ServiceManager? - nao-robot

I would like to stop and start ALTactileGesture service through ServiceManager during my app. I'm using Choregraphe and python boxes. I have tried different options to initiate ServiceManager but none of them works. Is there any way of doing this?
Edit:
I have already tried self.sm = session.service('ServiceManager') but did not work.
The idea is to stop ALTactileGesture as soon as the app has started:
(1) ServiceManager.stopService('ALTactileGesture') (see this)
and start/restart ALTactileGesture before the application ends:
(2) ServiceManager.startService('ALTactileGesture')
My question is how to reach ServiceManager so I can then use (1) and (2)?

You have to understand that the word "service" actually means two different things in NAOqi. See an explanation here:
NAOqi services (also called "modules"), that expose an API and are
registered to the ServiceDirectory. You can call them with qicli,
subscribe to their signals, etc.
systemd services, that are standalone executables packaged in an
Application Package, declared in it's manifest with a tag.
These are managed by ALServiceManager, who can start and stop them
(they will have their own process). For clarity's sake, these are
called "Executables" in this doc.
The confusion between the two is increased by the fact that a common
pattern is to write an executable whose sole purpose is to run a NAOqi
service, and sometimes to identify both with the same name (e.g. both
are called “ALFuchsiaBallTracker”).
Your problem here is that the NAOqi service ALTactileGesture is run by the executable registered under the ID ALTactileGesture-serv. So you need to do
ALServiceManager.stop("ALTactileGesture-serv")
(I just tested it, it works fine)
(edit) by the way, I'm not sure that actually stopping and starting ALTactileGesture is the best way of doing what you're trying to do (it seems a bit hacky to me), but if you want to do it that way, this is how :)

Just try this in robot shell (old style proxy connection):
$ python
import naoqi
s = naoqi.ALProxy("ALServiceManager", "localhost", 9559 )
s.stopService('ALTactileGesture')
>>> False
s.startService('ALTactileGesture')
>>> False # (a bit weird, but ...)
So I think it's not completely working, but at least you can connect to the ServiceManager as requested...

Related

'clarinet integrate' quickly fails and nothing is logged to console?

Following https://docs.hiro.so/smart-contracts/devnet I can't get the command clarinet integrate to work. I have installed Docker on my mac and am running version 0.28.0 of clarinet. Running command within 'my-react-app/clarinet' where all clarity related files live (contracts, settings, tests, and Clarinet.toml).
My guess is it could be an issue with Docker?
The issue was that I downloaded my Devnet.toml file from a repo that was configured incorrectly. The configuration I needed was:
[network]
name = "devnet"
I increased the CPU and Memory in Docker as well.
There is an issue when the command attempts to spin up the stacks explorer, but I was informed that there are several existing issues with the stacks explorer from clarinet integrate at the moment.
Depending on how the last devnet was terminated, you could have some containers running. This issue should be fixed in the next incoming release, meanwhile, you'd need to terminate this stale containers manually.
Apart from Ludo's suggestions, I'd also look into your Docker resources. The default CPU/memory allocation should allow you to get started with Clarinet, but just in case, you could alter it to see if that makes a difference. Here's my settings for your reference:
Alternatively, to tease things out, you could reuse one of the samples (eg: hirosystems/stacks-billboard) instead of running your project. See if the sample comes up as expected; if it does, there could be something missing in your project.

Is using nohup in production is a bad practice ? (how to run server forever)

I have Linux Droplet on Digital Ocean, and I want to run on it some services – like SpringbootWeb and React.js.
Clearly I need to run the servers all the time, without being depends
on the terminal on/off (I’m using Putty) and I am planning to do it ,
by using nohup.
I saw other methods like those
In spring boot (See 3. Installing Spring Boot Applications) and in npm.
But I prefer for now use nohup since it’s easier and simpler.
I there is problem with that approach and it considered “bad practice” for production ?
(And if does, what considered a good practice ?)
Edit
Now seeing that nohup not saving react running after closing Putty-console
found also this idea for deploying React on nginx. (Digital Ocean run nginx)
There's nothing wrong with it, but you would still need to create some sort of init script to start your app on boot and stop it on shutdown.
So on a Linux system you would typically want to use systemd unit files for this, and have the init system handle the lifecycle of your server application. The reference guide mentions it here, or refer to this as a more complete example.

How to use shp2pgsql

My question should be very simple to answer for anyone not being a self-taught newbie like me...
On this page is a cheatsheet concerning a function to be used in GIS/DB environnement : http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg
I would like to create a script allowing users to just have to click on it to launch the process, given the proper datas. But I don't understand how to use this. It obviously doesn't work in a Python console, nor directly in the windows console. How is it supposed to work ? What language is this ?
Thanks
shp2pgsql is indeed a command line tool. It comes with your PostgreSQL/PostGIS installation (usually) and, if not accessible via PATH-variable, can (usually) be run from within the /bin-folder in your PostgreSQL-Installation. You can also always 'make' the programm from source in any location yourself, if needed.
EDIT:
One way to set up a script (independent of whether you use it within qgis own python environment or not) would be to use Pythons subprocess (or os.system) module (check related question here) to write to shell and execute shp2pgsql.
A slightly more sophisitcated solution to (batch) insert (multiple) shapefiles via script could be to implement ogr2ogr via gdal/ogr module within python (check this blog). That, however, would require a working installation of the gdal core library, and the respective Python bindings (at least to use outside of QGIS Python environment, where it is pre-installed AFAIK), which can be tiresome at times. Once installed correctly, it offers a powerful (I dare say almighty) toolset for geodata management and manipulation via Python, though.
Apart from that, the blog link I provided also states the implementation of a batch insert script/tool (which operates ogr2ogr) in qgis 2.8 toolbox...maybe that can help you, either with your work directly or (via sourcecode) to point you in the direction of creating your own tool.

Calling Communicator.UIAutomation from Silverlight 4

I'm trying to instantiate a COM connection to Communicator 2007 from an Out of Browser Silverlight 4 app. I'm following some sample code - one (slightly different) example of which is here - but I'm getting an error when I run the following line:
dynamic communicator = AutomationFactory.CreateObject("Communicator.UIAutomation");
The error is:
Failed to create an object instance for the specified ProgID.
I've downloaded and installed what I believe is the right SDK, but OLEView isn't showing the DLL's as registered - is there something I need to do to register the DLL's in the SDK? regsvr32 doesn't seem to work.
Am I going about this all wrong? Is there a better option, perhaps with the Unified Communications Client (1.0 or 2.0) SDK?
Is Communicator running at the time? It must be running in order to use the API.
The above code works fine for me, when communicator is running, but I can replicate your error by ensuring that it isn't running when the above line gets hit.
I'm pretty sure the SDK is registered OK, as you'g get a slightly different error if it wasn't:
No object was found registered for specified ProgID.
With regards to the right SDK - it depends on what you're trying to achieve. The automation API (i.e. the one you're using) will allow you to automate the running instance of Communicator, so its great for e.g. obtaining presence info, starting IM conversations, placing phone calls etc uning the Communicator UI. You should only need to look at UCCA if its not guaranteed that Communicator will be running, or if you need to e.g. provide your own UI.
I blogged about the various APIs here
One more thing to bear in mind, if upgrading to Lync is an option, then the SDK has a whole bunch of really useful Silverlight/WPF controls built in - some info here

Getting proxy information on Linux programmatically

I am currently using libproxy to get the proxy information (if any) on RedHat and Debian Linux. It doesn't work all that well, but it's the only way I know I can use to get the proxy information from my code.
I need to stop using the lib since in most cases it doesn't recognize the proxy.
Is there any way to acquire the proxy information? What i mean is, is there a file (or group of files) i can read, or an env variable or an API or system call that i can use to get the information?
Gnome based code is OK, KDE might help as well but i am looking for something more generic.
The code is C.
Now, before anyone asks, I don't want to use libproxy anymore. Period. I don't want to start investigating why it doesn't work. I don't really want to know whether there is a new version of that lib. I know it might work, I just don't want to use it. i can't use it (just because). So please don't point me that way.
Code is appreciated.
thanks.
In linux, the "global proxy setting" is typically just environment variables that are usually set in /etc/profile. You can examine those variables to see what proxy is set.
The variables are:
http_proxy - the proxy for HTTP connections
ftp_proxy - the proxy for FTP connections
Using the Network Proxy Preferences tool under Gnome saves information in the GConf database. The path to the keys are /system/http_proxy and /system/proxy. You can read about the detail in those trees at this page.
You can access the GConf database using the library API. Note that GConf is based on GObject. To examine the contents of this tree using the command line, try the following:
gconftool-2 -R /system/http_proxy
This will provide a "name = value" listing of the tree, which may be usable in your application. Note that this requires a system() call, so it's not recommended for a deployed application, but it might help you get started.
GNOME has its own place to store the Proxy settings, and I am sure KDE or any other DE has its own place too. May be you can look for any mention of where Proxy settings should be store in the Linux Standard Base. That could hint you a standard of doing it irrespective of Distro or DE.
DE -> Desktop Environment
char* proxy = getenv("all_proxy");
This statement puts the value of the environment variable called all_proxy, which is used by the system as a global proxy, in your C variable.
To print it in bash, try env | grep 'all_proxy' | cut -d= -f 2.

Resources