|
| 1 | +--- |
| 2 | +title: 'Orangetool: General And Useful Scripts For Single-Board Computers' |
| 3 | +tags: |
| 4 | + - orangepi |
| 5 | + - script |
| 6 | + - single_board_computers |
| 7 | + - unix |
| 8 | + - library |
| 9 | +authors: |
| 10 | + - name: Sepand Haghighi |
| 11 | + orcid: 0000-0001-9450-2375 |
| 12 | + affiliation: 1 |
| 13 | +affiliations: |
| 14 | + - name: Moduland Co |
| 15 | + index: 1 |
| 16 | +date: 16 July 2017 |
| 17 | +--- |
| 18 | + |
| 19 | + |
| 20 | +# Summary |
| 21 | + |
| 22 | +Orangetool is a python library that consist of some general and useful scripts , developed for single-board computers like raspberry pi , orange pi and ... |
| 23 | +these scripts provides simple and fast way to control system in programming. |
| 24 | + |
| 25 | +Website : www.orangetool.ir |
| 26 | + |
| 27 | +``` |
| 28 | +import orangetool |
| 29 | +
|
| 30 | +#1- local_ip |
| 31 | +
|
| 32 | +local_ip=orangetool.local_ip() # this function return local ip of board as string |
| 33 | +
|
| 34 | +#2- global_ip |
| 35 | +
|
| 36 | +global_ip=orangetool.global_ip() # this function return global ip of board as string |
| 37 | +
|
| 38 | +#3- internet |
| 39 | +
|
| 40 | +status=orangetool.internet() #this function check internet connection and return True if internet connection is stable |
| 41 | +
|
| 42 | +#4- ping |
| 43 | +
|
| 44 | +ip_status=orangetool.ping(ip_address) #this function check ip and return True if this ip is available in network and False otherwise |
| 45 | +
|
| 46 | +#5- set_ip |
| 47 | +
|
| 48 | +set_ip("192.168.1.46","eth0") #this function set static ip for system |
| 49 | +
|
| 50 | +#6- mac |
| 51 | +
|
| 52 | +mac_dic=orangetool.mac() # return dict of all system net devices mac addresses |
| 53 | +
|
| 54 | +
|
| 55 | +
|
| 56 | +``` |
| 57 | + |
| 58 | +## RAM Functions |
| 59 | + |
| 60 | +``` |
| 61 | + |
| 62 | +#1- total ram |
| 63 | +
|
| 64 | +ram=orangetool.ram_total() #this function return total ram of the board |
| 65 | +
|
| 66 | +#2- free ram |
| 67 | +
|
| 68 | +ram=orangetool.ram_free() # this function return how much ram is available in the board |
| 69 | +
|
| 70 | +#3- ram percentage |
| 71 | +
|
| 72 | +ram=orangetool.ram_percent() # this function return used ram percentage |
| 73 | +
|
| 74 | +#4- used percentage |
| 75 | +
|
| 76 | +ram=orangetool.ram_used() # this function return used ram |
| 77 | +
|
| 78 | +#5- freeup |
| 79 | +
|
| 80 | +orangetool.freeup() # To free pagecache, dentries and inodes and return freeuped amount |
| 81 | +
|
| 82 | +``` |
| 83 | + |
| 84 | +## Storage Functions |
| 85 | + |
| 86 | +``` |
| 87 | +#1- mount_status |
| 88 | +
|
| 89 | +mount_details=orangetool.mount_status("sda1") # This function return mount addresses of input device |
| 90 | +
|
| 91 | +#2- storage_status |
| 92 | +
|
| 93 | +mount_details=orangetool.storage_status() # This function return all of the inserted storage and their status |
| 94 | +
|
| 95 | +#3- unmount |
| 96 | +
|
| 97 | +orangetool.unmount("/mnt/usb1") # This function unmount input device |
| 98 | +
|
| 99 | +#4- unmount_all |
| 100 | +
|
| 101 | +
|
| 102 | +orangetool.unmount_all() #This function unmount all of the mounted devices |
| 103 | +
|
| 104 | +#5- mount |
| 105 | +
|
| 106 | +orangetool.mount("sda1","/mnt/usb1") # This function mount input device in input addresses |
| 107 | +
|
| 108 | +``` |
| 109 | + |
| 110 | +## Display Functions |
| 111 | + |
| 112 | +``` |
| 113 | +#1- hdmi_on |
| 114 | +
|
| 115 | +orangetool.hdmi_on() # turn on hdmi port |
| 116 | +
|
| 117 | +#2- hdmi_off |
| 118 | +
|
| 119 | +orangetool.hdmi_off() # turn off hdmi port |
| 120 | +
|
| 121 | +#3- hdmi_size |
| 122 | +
|
| 123 | +orangetool.hdmi_size(1280,720) # this function change hdmi display resolution |
| 124 | +
|
| 125 | +``` |
| 126 | + |
| 127 | +## System Functions |
| 128 | + |
| 129 | +``` |
| 130 | +#1- sleep |
| 131 | +
|
| 132 | +orangetool.sleep() # put system in sleep mode |
| 133 | +
|
| 134 | +#2- halt |
| 135 | +
|
| 136 | +orangetool.halt() # poweroff system |
| 137 | +
|
| 138 | +#3- restart |
| 139 | +
|
| 140 | +orangetool.restart() # restart system |
| 141 | +
|
| 142 | +#4- wakeup |
| 143 | +
|
| 144 | +orangetool.wakeup(day=1,hour=0,minute=1) # set rtc wakeuptime |
| 145 | +
|
| 146 | +#5- get_temp |
| 147 | +
|
| 148 | +temp=orangetool.get_temp() # this function return cpu temperature as string |
| 149 | +
|
| 150 | +#6- uptime |
| 151 | +
|
| 152 | +time=orangetool.uptime() # this function return uptime of system |
| 153 | +
|
| 154 | +#7- idletime |
| 155 | +
|
| 156 | +time=orangetool.idletime() # this function return idle of system ( all cores) |
| 157 | +
|
| 158 | +
|
| 159 | +#8- version |
| 160 | +
|
| 161 | +orangetool.version() # return orangetool version for test |
| 162 | +
|
| 163 | +#9- check_update |
| 164 | +
|
| 165 | +orangetool.check_update # Return True if new version is available |
| 166 | +
|
| 167 | +``` |
| 168 | + |
| 169 | + |
| 170 | +# References |
0 commit comments