examples/ethernet_client_server/setup.py
Go to the documentation of this file.
1 # install the dependancies from pip
2 try:
3  from pip import main as pipmain
4 except:
5  from pip._internal import main as pipmain
6 pipmain(['install', 'numpy'])
7 pipmain(['install', 'python-crontab'])
8 pipmain(['install', 'opencv-python'])
9 pipmain(['install', 'pyrealsense2'])
10 pipmain(['install', 'cron_descriptor'])
11 
12 # using python-crontab, setup a job that is ran on the minute to check if the server is running.
13 # https://pypi.org/project/python-crontab/
14 from crontab import CronTab
15 #using the system crontab file as sudo is required for librealsense aquisition
16 system_cron = CronTab(tabfile='/etc/crontab', user=False)
17 #requires the shell enviroment as ./AlwaysRunningServer.bash
18 system_cron.env['SHELL'] = '/bin/bash'
19 job = system_cron.new(command="cd /home/$(ls /home/)/EtherSense; ./AlwaysRunningServer.bash >> /tmp/error.log 2>&1", user='root')
20 job.every_reboot()
21 i = 0
22 #this while loop means that the are entrys in the cron file for each 5 sec interval
23 while i < 60:
24  #the cron job is cd to the EtherSense dir then run AlwaysRunningServer.bash, logging to /temp/error.log
25  #have to use this $(ls /home/) to find home dir, assuming no other user spaces.
26  job = system_cron.new(command="sleep %i; cd /home/$(ls /home/)/EtherSense; ./AlwaysRunningServer.bash >> /tmp/error.log 2>&1"%i, user='root')
27 
28  # this line sets the frequance of server checking, stars for all time slices means every minute
29  job.setall('* * * * *')
30  system_cron.write()
31  i += 5
32 print('cron job set to run ' + job.description())
33 
34 
static std::string print(const transformation &tf)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41