def ProcessFile(fpath,output=None):
    import socket
    global __writer__
    
    if (fpath and os.path.exists(fpath) and (os.path.isfile(fpath))):
	if (__writer__):
	    while (1):
		try:
		    __writer__.sendFile(fpath,__eof__=__eof__)
		    # To do: Ensure the file was received and stored at the other end however for now we simply assume that happened because no exceptions.
		    #os.remove(fpath)
		    break
		except socket.error:
		    print 'INFO: Restarting Socket Writer on %s:%s.' % (__writer__.ipAddress, __writer__.portNum)
		    __writer__ = tcpipbridge.SocketWriter(__writer__.ipAddress, __writer__.portNum,retry=__writer__.retry)
		    if (__is_listener__):
			__writer__.send('@@@address=%s:%s@@@' % (listen_to_ip,listen_to_port))
		except Exception, ex:
		    print >> sys.stderr, 'EXCEPTION: %s' % (_utils.formattedException(details=ex))
	else:
	    if (output and os.path.exists(output) and os.path.isdir(output)):
		try:
		    dest = os.sep.join([output,os.path.basename(fpath)])
		    _utils.copyFile(fpath, dest, no_shell=True)
		    print >> sys.stdout, 'DEBUG: PROCESS --> %s --> %s' % (fpath,dest)
		    if (os.path.exists(dest)):
			os.remove(fpath)
		except Exception, ex:
		    print >> sys.stderr, 'EXCEPTION: %s' % (_utils.formattedException(details=ex))
예제 #2
0
    def _cleanup(fname,newName):
	if (os.path.exists(fname)) and (os.path.exists(newName)):
	    targetFolder = os.path.dirname(fname)
	    targetFname = os.sep.join([targetFolder,'copy%s'%(os.path.basename(fname))])
	    _utils.copyFile(newName,targetFname)
	else:
	    print >>sys.stderr, 'WARNING: Cannot copy the Zip file from "%s" to the target-folder of "%s".' % (fname,targetFname)
	pass
예제 #3
0
_utils._makeDirs(_dist_folder)

for fname,tup in d.iteritems():
    for t in tup:
        for f in t:
            _fname = os.sep.join(fname.replace(fp,'').split(os.sep)[1:])
            f_new = os.path.join(_dist_folder,_fname)
            _utils.makeDirs(f_new)
            try:
                _f = os.path.join(f_new,f.replace(os.path.join(fp,fname)+os.sep,''))
                _utils.makeDirs(_f)
                if (os.path.splitext(f)[-1] == '.pyc'):
                    print '(Dist) Removing "%s".' % (f)
                    os.rename(f,_f)
                else:
                    _utils.copyFile(f,_f)
            except Exception, _details:
                info_string = _utils.formattedException(details=_details)
                print '%s %s,%s' % (info_string,f,_f)

_deploy_folder = os.path.dirname(os.path.dirname(os.path.dirname(_dist_folder)))
_project_folder = os.path.join(_deploy_folder,os.sep.join(['django']))
_deploy_name = _deploy_folder.split(os.sep)[-1]
_deploy_folder = os.path.join(_deploy_folder,os.sep.join(['deployments','%s_deployment' % (_deploy_name)]))

for root, dirs, files in _utils.walk(_dist_folder,rejecting_re=_rx):
    for f in files:
        f1 = os.path.join(root,f)
        _f = os.sep.join(f1.replace(_dist_folder,'').split(os.sep)[1:])
        f2 = os.path.join(_deploy_folder,_f)
        isCopied = False