def my_dropbox(email, password, localpath, remotepath):
    from dbupload import DropboxConnection
    from getpass import getpass

    # email = raw_input("Enter Dropbox email address:")
    # password = getpass("Enter Dropbox password:"******"small_test_file.txt","w")
    # fh = open("small_test_file.txt","w")
    # fh.write("Small test file")
    # fh.write("Small test file")
    # fh.close()
    remote_file=remotepath.split('/')[-1]
    remote_dir=remotepath.split(remote_file)[0]

    try:
    # Create the connection
        conn = DropboxConnection(email, password)

        # Upload the file
        uploader=conn.upload_file(localpath,remote_dir,remote_file)
        public_url=conn.get_download_url(remote_dir,remote_file)
    except:
        print("Upload failed")
    else:
        print("Uploaded small_test_file.txt to the root of your Dropbox")
Exemplo n.º 2
0
def my_dropbox(email, password, localpath, remotepath):
    from dbupload import DropboxConnection
    from getpass import getpass

    # email = raw_input("Enter Dropbox email address:")
    # password = getpass("Enter Dropbox password:"******"small_test_file.txt","w")
    # fh = open("small_test_file.txt","w")
    # fh.write("Small test file")
    # fh.write("Small test file")
    # fh.close()
    remote_file = remotepath.split('/')[-1]
    remote_dir = remotepath.split(remote_file)[0]

    try:
        # Create the connection
        conn = DropboxConnection(email, password)

        # Upload the file
        uploader = conn.upload_file(localpath, remote_dir, remote_file)
        public_url = conn.get_download_url(remote_dir, remote_file)
    except:
        print("Upload failed")
    else:
        print("Uploaded small_test_file.txt to the root of your Dropbox")
Exemplo n.º 3
0
 def test_upload_small(self):
     conn = DropboxConnection(email, password)
     conn.upload_file("small_test_file.txt","/","small_test_file.txt")
#!/usr/bin/env python

from dbupload import DropboxConnection

#https://github.com/jncraton/PythonDropboxUploader

conn = DropboxConnection("*****@*****.**", "password")
conn.upload_file("local_file.txt","/remote/path/","remote_file.txt")
Exemplo n.º 5
0
 def test3_upload_small(self):
     conn = DropboxConnection(email, password)
     conn.upload_file("small_test_file.txt", "/", "small_test_file.txt")

folders=os.listdir(DATA_BASE_PATH)
try:
    # Create the connection
    conn = DropboxConnection(email, password)
    #List of files
    for folder in folders:
        list_of_files=glob.glob(str(DATA_BASE_PATH)+str(folder)+str("/*.csv"))
        for f in list_of_files:    
            
           
            if int(time.time())-int(os.stat(f).st_mtime)>THRESHOLD_TIME:
                
                dropbox_upload_log=open(DATA_BASE_PATH+"db_log.txt","w")
                dropbox_upload_log.write(str(f) +" will be uploaded")
                dropbox_upload_log.close()
                r=open(DATA_BASE_PATH+"db_log.txt","r")
                a=r.read()
                r.close()
                
                conn.upload_file(f,BASE_UPLOAD_PATH+str(folder),f)
                os.remove(f)
except:
    dropbox_upload_log=open(DATA_BASE_PATH+"db_log.txt","w")
    dropbox_upload_log.write("Upload failed"+str(int(time.time())))
    dropbox_upload_log.close()
else:
    pass

from dbupload import DropboxConnection
from getpass import getpass

email = raw_input("Enter Dropbox email address:")
password = getpass("Enter Dropbox password:"******"small_test_file.txt","w")
fh.write("Small test file")
fh.close()

try:
    # Create the connection
    conn = DropboxConnection(email, password)
    
    # Upload the file
    conn.upload_file("small_test_file.txt","/","small_test_file.txt")
except:
    print("Upload failed")
else:
    print("Uploaded small_test_file.txt to the root of your Dropbox")
Exemplo n.º 8
0
#!/usr/bin/python
from dbupload import DropboxConnection
conn = DropboxConnection("*****@*****.**", "2P236HWgz")
fname = 'temperaturen.txt'
conn.upload_file(fname, "/", fname)
            u = urllib2.urlopen(url)
            f = open(file_path, 'wb')
            meta = u.info()
            file_size = int(meta.getheaders("Content-Length")[0])
            print "Downloading: %s Bytes: %s" % (url, file_size)

            file_size_dl = 0
            block_sz = 8192
            while True:
                buffer = u.read(block_sz)
                if not buffer:
                    break

                file_size_dl += len(buffer)
                f.write(buffer)
                status = r"%10d  [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
                status = status + chr(8)*(len(status)+1)
                print status,
            print "File saved as '%s'." % file_path
            f.close()

            print "Uploading file to Dropbox..."
            conn = DropboxConnection(dropbox_user, dropbox_password)
            conn.upload_file(file_path, '/Petroleum Contracts/', name)
            print "File uploaded to Dropbox."





Exemplo n.º 10
0
def NewArticle(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login/')

    user_id = request.user.get_profile()
    if request.POST:
        form = ArticleForm(request.POST, request.FILES)
        if form.is_valid():
            art_desc=form.cleaned_data['art_desc']
            alb_title=form.cleaned_data['alb_title']
            alb_desc=form.cleaned_data['alb_desc']
            gps_file=form.cleaned_data['gps_file']
            sport_id = form.cleaned_data['sport']

            if alb_title == '':
                alb_title = art_desc

            art_alb = Album.objects.create(alb_title=alb_title, description=alb_desc, date=datetime.datetime.now())
            art_alb.save()

            picture1=form.cleaned_data['picture1']
            pic_title1=form.cleaned_data['pic_title1']
            if picture1 is not None:
                Picture.objects.create(pic_title=pic_title1, pic=picture1, album=art_alb)

            picture2=form.cleaned_data['picture2']
            pic_title2=form.cleaned_data['pic_title2']
            if picture2 is not None:
                Picture.objects.create(pic_title=pic_title2, pic=picture2, album=art_alb)

            picture3=form.cleaned_data['picture3']
            pic_title3=form.cleaned_data['pic_title3']
            if picture3 is not None:
                Picture.objects.create(pic_title=pic_title3, pic=picture3, album=art_alb)

            picture4=form.cleaned_data['picture4']
            pic_title4=form.cleaned_data['pic_title4']
            if picture4 is not None:
                Picture.objects.create(pic_title=pic_title4, pic=picture4, album=art_alb)

            picture5=form.cleaned_data['picture5']
            pic_title5=form.cleaned_data['pic_title5']
            if picture5 is not None:
                Picture.objects.create(pic_title=pic_title5, pic=picture5, album=art_alb)

            article = Article.objects.create(date=datetime.datetime.now(),sport_id=Sport.objects.get(id=sport_id),gps_file=gps_file,art_alb=art_alb,user_id=user_id,description=art_desc)
            article.save()

            #upload gps_file to DB:
            email = "*****@*****.**"
            password = "******"
            gps_filename=str(gps_file)
            file="./media/gps_files/"+gps_filename
            try:
                # Create the connection
                conn = DropboxConnection(email, password)

                # Upload the file
                conn.upload_file(file,"/Public/KML_FILES/",file)
            except:
                print("Upload failed")
            else:
                print("Uploaded "+file+" to your Dropbox")
            #end of upload

            articles_list = Article.objects.order_by('-date')[:10]
            context = {
                'users': user_id,
                'articles_list': articles_list,
                }
            return render_to_response('main/home.html', context, context_instance=RequestContext(request))
    else:
        form=ArticleForm()
    return render_to_response('main/new_article.html', {'form':form, 'users':user_id,}, context_instance=RequestContext(request))
Exemplo n.º 11
0
now=datetime.datetime.now(timezone('Asia/Kolkata'))

BASE_UPLOAD_PATH="/SmartMeter/GroundTruth/Amarjeet/"
DATA_BASE_PATH="/root/data/"
BASE_PATH=str(now.day)+"_"+str(now.month)+str("/")
FILENAME=str(now.hour)+".csv"

print BASE_PATH
print FILENAME

#Path in Dropbox in which to upload the data
base_upload_path = BASE_UPLOAD_PATH + BASE_PATH
folders=os.listdir(DATA_BASE_PATH)

try:
    # Create the connection
    conn = DropboxConnection(email, password)
    for folder in folders:
        #List of files
        list_of_files=glob.glob(str(DATA_BASE_PATH)+str(folder)+str("/*.csv"))
        print list_of_files
        for FILENAME in list_of_files:
					#Upload the File
					print FILENAME +" will be uploaded"
					conn.upload_file(FILENAME,base_upload_path,FILENAME)
					os.remove(FILENAME)
except:
    print("Upload failed")
else:
    pass