Skip to content

Commit 0cdcc32

Browse files
feat : freeup function added
1 parent fad89ba commit 0cdcc32

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ global_ip=orange_tool.global_ip() # this function return global ip of board as s
4545

4646
status=orangetool.internet() #this function check internet connection and return True if internet connection is stable
4747

48+
#4- ping
49+
50+
ip_status=orangetool.ping(ip_address) #this function check ip and return True if this ip is available in network and False otherwise
51+
4852
```
4953

5054
## RAM Functions ##

src/orangetool.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,26 @@ def ping(ip,packet_number=3,DEBUG=False):
212212
if DEBUG==True:
213213
print(str(e))
214214
return "Error"
215+
def freeup(DEBUG=False):
216+
'''
217+
To free pagecache, dentries and inodes:
218+
:param DEBUG: Flag for using Debug mode
219+
:type DEBUG:bool
220+
:return: Amount of freeuped ram as string and converted by convert_bytes()
221+
'''
222+
try:
223+
RAM_before=int(ram_free(convert=False))
224+
output = sub.Popen(["sync", ";", "echo", "3", ">", "/proc/sys/vm/drop_caches"], stdout=sub.PIPE,stderr=sub.PIPE)
225+
RAM_after=int(ram_free(convert=False))
226+
freeuped_ram=RAM_after - RAM_before
227+
if freeuped_ram>0:
228+
return convert_bytes(freeuped_ram)
229+
else:
230+
return convert_bytes(0)
231+
except Exception as e:
232+
if DEBUG==True:
233+
print(str(e))
234+
return "Error"
235+
215236

216237

0 commit comments

Comments
 (0)