Ejemplo n.º 1
0
    def add(self, song_id):
        song = Song.objects.get(id=song_id)
        user = User.objects.get(id=self.user_id)

        try:
            queue = Queue.objects.get(Song=song)
        except ObjectDoesNotExist:
            queue = Queue(Song=song)
            queue.save()
        queue.User.add(user)

        return song_id
Ejemplo n.º 2
0
    def add(self, song_id):
        song = Song.objects.get(id=song_id)
        user = User.objects.get(id=self.user_id)

        try:
            queue = Queue.objects.get(Song=song)
        except ObjectDoesNotExist:
            queue = Queue(
                Song=song
            )
            queue.save()
        queue.User.add(user)

        return song_id
Ejemplo n.º 3
0
    def add(self, song_id):
        song = Song.objects.get(id=song_id)
        user = User.objects.get(id=self.user_id)

        try:
            queue = Queue.objects.get(Song=song)
        except ObjectDoesNotExist:
            queue = Queue(
                Song=song,
                Created=fuzzy_datetime(datetime.now()),
            )
            queue.save()
        queue.User.add(user)

        return song_id
Ejemplo n.º 4
0
def Enqueue_Put(Uri=None, File=None):
    if File is None:
	raise StorageError('Enqueue_Get(): File can not be None')

    if Uri is None:
	raise StorageError('Enqueue_Get(): Uri can not be None')

    Q = Queue()
    Q.status  = 'Q'
    Q.action  = 'P'
    Q.uri     = Uri
    Q.file = File
    Q.service = Service
    Q.uqid    = GetUniqueQueueID(Uri)
    Q.save()
    return Q
Ejemplo n.º 5
0
	FtpHandler = FTP()
	FtpHandler.connect(FtpData['hostname'], FtpData['port'])
	FtpHandler.login(FtpData['username'], FtpData['password'])
	FtpHandler.cwd(FtpData['path'])
    except error_perm, e:
	raise StorageError('GetFile(): %s' % str(e))

    try:
	FileSize = FtpHandler.size(FtpData['filename'])
    except error_perm, e:
	raise StorageError('GetFile(): Getting filesize: %s' % str(e))

    if Queue.file is None:
	File = RegisterFile(Queue.service, FtpData['filename'], str(FileSize) + 'b')
        Queue.file = File
        Queue.save()

    try:
	LocalFile = open(Queue.service.localpath + Queue.file.pfilename,'wb')
    except IOError as e:
	DeleteFile(File.ufid)
	raise StorageError('GetFile(): %s [%s]' % (e.strerror, Queue.service.localpath + Queue.file.pfilename))


    CBack = CallBack()
    CBack.localfile = LocalFile
    CBack.queue	    = Queue

    try:
	FtpHandler.retrbinary('RETR %s' % FtpData['filename'],CBack.Write)
    except error_perm, e: