示例#1
0
def uninstall():
    """uninstall from ~/bin/crashplan"""
    # uninstall launchd plist file
    plist = "com.myowncrashplan.plist"
    launchagents = os.path.join(os.environ['HOME'], "Library", "LaunchAgents")
    process("launchctl unload {0!s}".format(os.path.join(launchagents, plist)))
    os.unlink(os.path.join(launchagents, plist))
    
    inst_dest = os.path.join(os.environ['HOME'],"bin","crashplan")
    shutil.rmtree(inst_dest)
    
示例#2
0
def getReleaseMetadata(releaseTopDir):
    """
    getReleaseMetadata:
      Collects info from scram internal files
    """
    # These are scram hardcoded default paths: 
    envFile = releaseTopDir+'/.SCRAM/Environment'
    releaseMetadata = {}

    inputFile = open(envFile, 'r')
    for line in inputFile.readlines():
        process(line, releaseMetadata)
    return releaseMetadata
示例#3
0
def install():
    """install in ~/bin/crashplan"""
    for inst in manifest:
        if not os.path.exists(inst):
            print("Cannot find {0!s}. Are you sure you're in the source folder.".format(ins))
            sys.exit()
    
    inst_dest = os.path.join(os.environ['HOME'],"bin","crashplan")
    os.makedirs(inst_dest)
    for inst in manifest:
        shutil.copy(inst, inst_dest)
    
    # install launchd plist file
    plist = "com.myowncrashplan.plist"
    launchagents = os.path.join(os.environ['HOME'], "Library", "LaunchAgents")
    shutil.copy(plist, launchagents)
    process("launchctl load {0!s}".format(os.path.join(launchagents, plist)))
示例#4
0
    def run2(self):
        """run the backup command"""
        self._create_exclude_file()
        self.log.info(self.cmd)

        st, rt = process(shlex.split(self.cmd))
        self._calculate_size(rt)

        self._remove_exclude_file()
示例#5
0
    def remoteCommand(self, command):
        """perform a remote command on the server and get the response"""
        remote = ["ssh", "-q", self.settings('server-address')]
        remote.append(command)

        st, rt = process(remote)
        if st != 0:
            self.log.error(f"(remoteCommand): {command}")
            self.log.error(f"(remoteCommand): {st:d} {rt}")

        return st, rt
示例#6
0
    def run(self):
        """run the backup command"""
        self._create_exclude_file()
        self.log.info(self.cmd)

        st, rt = process(shlex.split(self.cmd))
        if self.dry_run:
            self._calculate_size(rt)
            #print("DRY_RUN",st,rt)

        self._remove_exclude_file()
        return self._interpretResults(st, rt)
示例#7
0
def ping(host):
    """
    Returns True if host (str) responds to a ping request.
    Remember that a host may not respond to a ping (ICMP) request even if the host name is valid.
    
    Note: on Windows this function will still return True if you get a Destination Host Unreachable
          error.
    """
    # Option for the number of packets as a function of 
    param = '-n' if platform.system().lower() == 'windows' else '-c'
    # Building the command. Ex: "ping -c 1 google.com"
    command = ['ping', '-q', param, '1', '-W5', host]

    st, _rt = process(command)
    return st == 0
示例#8
0
    def remoteCopy(self, filename, dest=None):
        """scp file server:/path/to/dir"""
        if dest:
            dest_filename = os.path.basename(dest)
        else:
            dest_filename = os.path.basename(filename)
        remote = ["scp", filename, self.settings('server-address')+":"+ 
                  os.path.join(self.settings("backup-destination"), 
                               self.settings('local-hostname'), dest_filename)]

        st, rt = process(remote)

        if st != 0:
            self.log.error(f"(remoteCommand): {remote}")
            self.log.error(f"(remoteCommand): {st:d} {rt}")
            raise CrashPlanError(f"ERROR: remote command failed. ({remote})")
示例#9
0
 def parseRequest(self,file):
     # Disable  try:
     if 0 == 0 :
     #try:
         f = open(file,'r')
         input = {}    
         for line in f.readlines():
             process(line, input)
         # Store input values from the request in attributes
         # (mapping to the RefDB used variable names):
         self.project = input['Application']
         self.release = input['Version'    ]
         # Handle multiple geometry files:
         if input.has_key("NumberOfGeometryFiles"):
             self.geomFileNum = int(input['NumberOfGeometryFiles'])
             for i in range(self.geomFileNum):
                 self.geomFilesList.append(Geometry(input,str(i)))
                 # DO check right away during parsing
                 infoOut("Validating file "+self.geomFilesList[i].filePath +" ...")
                 if not (self.geomFilesList[i]).valid():
                     self.error("Invalid geometry file: "+self.geomFilesList[i].filePath)
         # Add paths to multiple Geometry versions.
         if input.has_key("NumberOfGeometryXMLversions"):
             self.geompath_num=int(input['NumberOfGeometryXMLversions'])
             for i in range(self.geompath_num):
                 self.geompath_list.append(GeometryPath(input,str(i)))
         # Get darfile related info: 
         self.darball=DARball(input) # an object            
         # List of Executables to be searched in runtime PATH:
         if input.has_key("ExecutablesList"):
             self.executables=string.split(input['ExecutablesList'],";")
         # List of applications to  be built from sources:
         if input.has_key("NumberOfExecutables"):
             self.numExe = int(input['NumberOfExecutables'])
             for i in range(self.numExe):
                 if input.has_key('Application_'+str(i)):
                     self.applList.append(Application(input,str(i)))# each an object
         if not self.numExe:
             raise "zero_num_exe"
         # Define a few DAR hooks that will extend scram runtime environment
         # by setting special DAR variables
         for name in input.keys():
             # DAR_PRE_ hook:
             if name[0:8] == "DAR_PRE_":
                 self.darHooks[name]=input[name]
             # DAR_POST_ hook:
             if name[0:9] == "DAR_POST_":
                 self.darHooks[name]=input[name]
             # DAR_ROOTRC hook:
             if name=="DAR_ROOTRC":
                 self.darHooks[name]=input[name]                
             # DAR_IGNORE_FILE - a separate hook that helps to pass the file with the
             # runtime environment variables to be ignored in dar:
             if name == "DAR_ignore_file":
                 self.DAR_ignore_file = input[name]
             # get list of tools to be removed from the project
             # configuration before packaging:
             if name == "DAR_remove_tools":
                 self.DAR_remove_tools = string.split(input[name],";")
         
     # For all SCRAM managed projects use DAR2: 
     self.packager = DAR2Packager(self) 
     self.timingLog('input file processed')
示例#10
0
import cv2
from Utils import process, Buffers
from brain import CNNModel
import torch
from torch.autograd import Variable

if __name__ == "__main__":
    device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
    model = CNNModel().to(device)
    model.load_state_dict(torch.load("./weightedmodel.pth"))
    L = Buffers(12)
    cap = cv2.VideoCapture(0)
    while True:
        ret, frame = cap.read()
        if frame is not None:
            tframe = process(frame)
            pframe = tframe.copy()
            tframe = tframe.reshape(1, 1, 50, 50)
            tframe = torch.from_numpy(tframe)
            tframe = tframe.type(torch.FloatTensor)
            tframe = (Variable(tframe)).to(device)
            out = model(tframe)
            L.push(out)
            font = cv2.FONT_HERSHEY_SIMPLEX
            frame = cv2.putText(frame, str(L.result()), (50, 50), font, 1,
                                (255, 0, 0), 2, cv2.LINE_8)
            cv2.imshow("HASIYE AAP CAMERE ME HAI!!", frame)
            cv2.imshow("cool ", pframe)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break