class Transfer(Rsync, SFtp, Copy): def __init__(self, method): self.methodDict = ["rsync", "copy", "sftp"] self.setServerFlag = 0 self.method = method if self.method not in self.methodDict: raise TransferError(method + " type of transfer is not " + "implemented") def setServerParams(self, server, uname, passwd): if self.method == "rsync": self.rsyncObj = Rsync(server, uname, passwd) elif self.method == "sftp": self.sftpObj = SFtp(server, uname, passwd) def copy(self, src, dest, toServer=None): self.copyObj = Copy() if self.method == "rsync": if not toServer == None: self.rsyncObj.run(src, dest, toServer) else: raise TransferError("Did not specify transfer " + "direction") return if os.path.isdir(src): if self.method == "sftp": raise TransferError("Cannot transfer directories " + "using sftp") else: self.copyObj.copytree(src, dest) else: if self.method == "sftp": if os.path.isdir(dest): raise TransferError("Cannot transfer to dir " + "using sftp") self.sftpObj.copy_file(src, dest) else: self.copyObj.copy(src, dest)
def copy(self, src, dest, toServer=None): self.copyObj = Copy() try: if self.method == "rsync": if not toServer == None: self.rsyncObj.run(src, dest, toServer) else: raise TransferError("Did not specify transfer "+\ "direction") return if os.path.isdir(src): if self.method == "sftp": raise TransferError("Cannot transfer directories "+\ "using sftp") else: self.copyObj.copytree(src, dest) else: if self.method == "sftp": if os.path.isdir(dest): raise TransferError("Cannot transfer to dir "+\ "using sftp") self.sftpObj.copy_file(src, dest) else: self.copyObj.copy(src, dest) print "Copying "+src+" to "+dest except IOError: print "Did not transfer "+src+" to "+dest
def go(self): user_path = str( raw_input() ) sel = pm.ls(selection=True) sel_orig = Copy(sel) for obj in sel: #print( type(obj) ) ## Bail early if it's not a transform node if not isinstance(obj, pm.core.nodetypes.Transform): continue pm.select(obj, replace=True, hierarchy=True) suf = self.mesh_suffix dir = user_path.replace('\\', '/' ) dest = dir + '/' + obj.name() + suf + '.fbx' fmt = 'FBX export' pm.exportSelected( dest, type=fmt, es=True ) pm.select( clear=True )
def _Prepare(self): baseProblem._prepare(self) if asarray(self.implicitBounds).size == 1: self.implicitBounds = [-self.implicitBounds, self.implicitBounds] self.implicitBounds.sort()# for more safety, maybe user-provided value is negative if hasattr(self, 'solver'): if not self.solver.iterfcnConnected: if self.solver.funcForIterFcnConnection == 'f': if not hasattr(self, 'f_iter'): self.f_iter = PythonMax(self.n, 4) else: if not hasattr(self, 'df_iter'): self.df_iter = True if self.prepared == True: return # TODO: simplify it self._makeCorrectArgs() for s in ('f', 'df', 'd2f', 'c', 'dc', 'd2c', 'h', 'dh', 'd2h'): derivativeOrder = len(s)-1 self.nEvals[Copy(s)] = 0 Attr = getattr(self, s, None) if Attr is not None and (not isinstance(Attr, (list, tuple)) or len(Attr) != 0) : setattr(self.userProvided, s, True) A = getattr(self,s) if type(A) not in [list, tuple]: #TODO: add or ndarray(A) A = (A,)#make tuple setattr(self.user, s, A) else: setattr(self.userProvided, s, False) if derivativeOrder == 0: setattr(self, s, lambda x, IND=None, userFunctionType= s, ignorePrev=False, getDerivative=False: \ self.wrapped_func(x, IND, userFunctionType, ignorePrev, getDerivative)) # setattr(self, s, lambda x, IND=None, userFunctionType= s, ignorePrev=False, getDerivative=False, \ # _linePointDescriptor = None: \ # self.wrapped_func(x, IND, userFunctionType, ignorePrev, getDerivative, _linePointDescriptor)) elif derivativeOrder == 1: setattr(self, s, lambda x, ind=None, funcType=s[-1], ignorePrev = False, useSparse=self.useSparse: self.wrapped_1st_derivatives(x, ind, funcType, ignorePrev, useSparse)) elif derivativeOrder == 2: setattr(self, s, getattr(self, 'user_'+s)) else: self.err('incorrect non-linear function case') self.diffInt = ravel(self.diffInt) # TODO: mb get rid of the field self.vectorDiffInt = self.diffInt.size > 1 if self.scale is not None: self.scale = ravel(self.scale) if self.vectorDiffInt or self.diffInt[0] != ProbDefaults['diffInt']: self.info('using both non-default scale & diffInt is not recommended. diffInt = diffInt/scale will be used') self.diffInt = self.diffInt / self.scale #initialization, getting nf, nc, nh etc: for s in ['c', 'h', 'f']: if not getattr(self.userProvided, s): setattr(self, 'n'+s, 0) else: setNonLinFuncsNumber(self, s) self.prepared = True
def __init__(self): Copy.__init__(self)
# -*- coding: utf-8 -*- import errors from argparser import ArgParser from copy import Copy if __name__ == "__main__": try: arg_parser = ArgParser() file_from = arg_parser.get_from() file_to = arg_parser.get_to() copy = Copy(file_from, file_to) copy.make_copy() except (errors.NoArgumentsPassed, errors.ToManyArgumentsPassed, errors.NotMuchArgumentsCount, errors.FileForCopyFromNotFound) as e: print(e.message)