I need to make a python script (python 3), that does I am newbie using python
identify the current OS because dev guys work on iPad/surface/windows workstation, Linux servers, some mac minis and so on ...
the goal of that script is to clean disk (part I already made for windows machines only for now), download & unpack packages hosted on artifactory and git repos ; the script will be run from a jenkins file at last.
import ctypes
import os
import platform
import sys
def get_free_space_gb(dirname):
"""Return Windows specific folder/drive free space (in GB)."""
free_bytes = ctypes.c_ulonglong(0)
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(dirname), None, None, ctypes.pointer(free_bytes))
return free_bytes.value / 1024 / 1024 / 1024
if get_free_space_gb("f:") > 50 :
print ("Drive free space is OK")
quit(0)
else:
print ("Drive free space is KO")
quit(1)
artifactory site propose that so I think it is ok:
from artifactory import ArtifactoryPath
path = ArtifactoryPath(
"http://repo.jfrog.org/artifactory/distributions/org/apache/tomcat/apache-tomcat-7.0.11.tar.gz")
with path.open() as fd:
with open("tomcat.tar.gz", "wb") as out:
out.write(fd.read())
and
So I need help to validate/upgrade/apply your advice for the first few lines I made over here. I need assistance (example would be appreciated), to get a remote repo.
0 Answers