Ejemplo n.º 1
0
def makeMulArrayPair(arrays):
    temp = []

    for i in arrays:

        te = []
        for j in i:
            d = ms.replaceBy_String(j, ' ', '_')
            te.append(d)

        temp.append(te)

    arrays = temp
    arr = []
    first = arrays[0]
    for i in range(1, len(arrays)):
        second = arrays[i]

        first = makeArrayPair(first, second)

    temp = []
    for i in first:
        t2 = []
        d = ms.distributeString(i, ' ')

        for i in d:
            t = ms.replaceBy_String(i, '_', ' ')

            t2.append(t)
        temp.append(t2)
    return temp
Ejemplo n.º 2
0
        def fun(file,chunk=1024*1024*5):
            fName,size=self.get_file_name(file)

            #First Stage
            t=str(time.time())
            t=ms.replaceBy_String(t,'.','_')
            fName=t+'-'+fName

            data=ad.assValue(['fName','fsize'],[fName,str(size)],'FF',start='@!$%~(*&~$',end='%~#*!%$~#@')
            self.sendMsg(data)

            #Second Stage
            file=open(file,'rb')

            while True:

                d=file.read(chunk)

                if d==b'':
                    break

                data=encb(d)
                data=data.decode('utf-8')
                data=ad.assValue(['Data','fName'],[data,fName],'FM',start='@!$%~(*&~$',end='%~#*!%$~#@')
                self.sendMsg(data)


            #Third Stage

            time.sleep(2)

            data=ad.assValue(['Data','fName','eType'],['End',fName,True],'FE',start='@!$%~(*&~$',end='%~#*!%$~#@')
            self.sendMsg(data)
    def recv_file_f(self, data, end):
        #Clear
        location = self.location
        t = time.time()
        t = ms.replaceBy_String(str(t), '.')
        hinte = '^%&@f__@&*s_'
        hints = '@->@n!~_'

        hint = '*&@->' + end
        size = ms.find_mid_text(data, hinte, hint)
        fName = ms.find_mid_text(data, hints, hinte)
        file = location + t + '_' + fName
        print(file)
        f = open(file, 'wb')

        self.file_status[file] = True

        self.flsize[fName] = 0
        size = int(size)
        mb = self.get_mb(size)
        if (mb > 5):
            self.chunk = 1024 * 1024
        else:
            self.chunk = 1024

        data = "File :" + fName + " Size :" + str(size)
        self.alert_message(data)
        return [f, size]
Ejemplo n.º 4
0
        def fun(file,chunk=1024*1024*5,function=None,args=None,tfs={}):
            fName,size=self.get_file_name(file)
            fn=fName
            #First Stage
            t=str(time.time())
            t=ms.replaceBy_String(t,'.','_')
            fName=t+'-'+fName

            tfs[file]=fName

            self.fileNames[fName]=fn
            self.fileSize[fName]=size
            self.fileStatus[fName]=0
            self.fileTempSize[fName]=0
            self.fileFlow[fName]=True


            data=ad.assValue(['fName','fsize'],[fName,str(size)],'FF',start='@!$%~(*&~$',end='%~#*!%$~#@')
            self.sendMsg(data)

            #Second Stage
            file=open(file,'rb')
            cond=True
            while True and cond:
                cond=self.fileFlow[fName]

                d=file.read(chunk)
                length=len(d)
                if d==b'':
                    break
                self.fileTempSize[fName]=self.fileTempSize[fName]+length
                if function is not None:
                    function(args+[cond],self.fileTempSize[fName],size)
                self.fileStatus[fName]=1

                data=encb(d)
                data=data.decode('utf-8')
                data=ad.assValue(['Data','fName'],[data,fName],'FM',start='@!$%~(*&~$',end='%~#*!%$~#@')
                self.sendMsg(data)


            #Third Stage

            time.sleep(2)

            if cond:
                data=ad.assValue(['Data','fName','eType'],['End',fName,True],'FE',start='@!$%~(*&~$',end='%~#*!%$~#@')
            else:
                data=ad.assValue(['Data','fName','eType'],['End',fName,False],'FE',start='@!$%~(*&~$',end='%~#*!%$~#@')



            self.fileStatus[fName]=2
            if function is not None:
                function(args+[cond,fName],self.fileTempSize[fName],self.fileSize[fName],True)

            self.sendMsg(data)

            self.clearFileLog(fName,'F')
    def get_file_name(self, file):
        dfile = file[::-1]
        index = None
        try:
            index = dfile.index('\\')
        except:
            try:
                index = dfile.index('/')
            except:
                index = None

        if index == None:

            file = ms.replaceBy_String(file, ' ', '_')
            return file
        else:
            cu = len(file) - (1 + index)
            fName = file[cu + 1:]
            fName = ms.replaceBy_String(fName, ' ')
            return fName
Ejemplo n.º 6
0
        def fun(file,chunk=1024*1024*5,nt=False,fileTempName=None,onStart=None,onEnd=None,toWhom='_None',toType='_None'):
            fName,size=self.get_file_name(file)

            #First Stage
            if nt:
                t=str(time.time())
                t=ms.replaceBy_String(t,'.','_')
                fName=t+'-'+fName
            else:
                fName=fileTempName

            self.fileSize[fName]=size
            self.fileTempSize[fName]=0
            self.fileFlow[fName]=True

            onStart()
            data=ad.assValue(['fName','fsize','toWhom','toType'],[fName,str(size),toWhom,toType],'FF',start='@!$%~(*&~$',end='%~#*!%$~#@')
            self.sendMsg(data)


            #Second Stage
            file=open(file,'rb')

            while True and self.fileFlow[fName]:

                d=file.read(chunk)
                length=len(d)
                if d==b'':
                    break
                self.fileTempSize[fName]=self.fileTempSize[fName]+length
                data=encb(d)
                data=data.decode('utf-8')
                data=ad.assValue(['Data','fName'],[data,fName],'FM',start='@!$%~(*&~$',end='%~#*!%$~#@')

                self.sendMsg(data)


            #Third Stage

            time.sleep(2)


            if self.fileFlow[fName]:
                onEnd(fName)

                data=ad.assValue(['Data','fName','eType'],['End',fName,True],'FE',start='@!$%~(*&~$',end='%~#*!%$~#@')
            else:
                data=ad.assValue(['Data','fName','eType'],['End',fName,False],'FE',start='@!$%~(*&~$',end='%~#*!%$~#@')

            self.sendMsg(data)
            self.clearFileLog3(fName)
def genTable(layers):
    columns=['sno','input','output','lr','ob','ow']

    t=[]
    for i in range(layers):
        d=['hb'+str(i),'hw'+str(i)]
        t=t+d
    columns=columns+t

    dtime=str(time.time())
    table=ms.replaceBy_String(dtime,'.')

    cb=db.cb1(mycursor,'abc')

    cb.createTableTextSize(table,columns)
    return table
Ejemplo n.º 8
0
    def send_file(self,file,chunk=1024*1024*5):
        fName,size=self.get_file_name(file)
        fn=fName
        #First Stage
        t=str(time.time())
        t=ms.replaceBy_String(t,'.','_')
        fName=t+'-'+fName

        self.fileNames[fName]=fn
        self.fileSize[fName]=size
        self.fileStatus[fName]=0
        self.fileTempSize[fName]=0

        data=ad.assValue(['fName','fsize'],[fName,str(size)],'FF')
        self.sendMsg(data)

        #Second Stage
        file=open(file,'rb')
        while True:
            d=file.read(chunk)
            length=len(d)
            if d==b'':
                break
            self.fileTempSize[fName]=self.fileTempSize[fName]+length
            self.fileStatus[fName]=1

            data=encb(d)
            data=data.decode('utf-8')
            data=ad.assValue(['Data','fName'],[data,fName],'FM')
            self.sendMsg(data)


        #Third Stage

        time.sleep(2)

        data=ad.assValue(['Data','fName'],['End',fName],'FE')

        self.fileStatus[fName]=2
        if self.function is not None:
            self.function(fName)
        self.sendMsg(data)
Ejemplo n.º 9
0
    def sendHalf_file(self,file,startAt,chunk=1024*1024*5):

        fName,size=self.get_file_name(file)
        fn=fName
        #First Stage
        t=str(time.time())
        t=ms.replaceBy_String(t,'.','_')
        fName=t+'-'+fName

        data=ad.assValue(['fName','fsize'],[fName,str(size)],'HF')
        self.sendMsg(data)

        #Second Stage
        file=open(file,'rb')
        flush=file.read(startAt)
        length=len(flush)

        self.hfileNames[fName]=fn
        self.hfileSize[fName]=size
        self.hfileStatus[fName]=0
        self.hfileTempSize[fName]=length

        del flush
        while True:
            d=file.read(chunk)
            if d==b'':
                break
            self.hfileTempSize[fName]=self.hfileTempSize[fName]+length
            self.hfileStatus[fName]=1
            data=encb(d)
            data=data.decode('utf-8')
            data=ad.assValue(['Data','fName'],[data,fName],'HM')
            self.sendMsg(data)


        #Third Stage

        time.sleep(2)
        self.hfileStatus[fName]=2
        data=ad.assValue(['Data','fName'],['End',fName],'HE')
        self.sendMsg(data)