Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes clear what kind of path is expected (\) + some changes related to that #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions upload_to_drive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3

"""Example cooment to make pylint stop giving me errors."""
"""Example comment to make pylint stop giving me errors."""

import datetime
import hashlib
Expand Down Expand Up @@ -28,10 +28,8 @@
APPLICATION_NAME = 'Drive Sync'

# Declare full path to folder and folder name
FULL_PATH = r'PUT YOUR FULL FOLDER PATH HERE'
DIR_NAME = 'PUT YOUR FOLDER NAME HERE'
# Or simply
# DIR_NAME = FULL_PATH.split('/')[-1]
FULL_PATH = r'PUT YOUR FULL FOLDER PATH HERE' # should be like r'C:\Users\ME\Desktop\'
DIR_NAME = FULL_PATH.split('\\')[-1] #

# Don't really need it here
GOOGLE_MIME_TYPES = {
Expand Down Expand Up @@ -76,8 +74,8 @@ def folder_upload(service):
parents_id = {}

for root, _, files in os.walk(FULL_PATH, topdown=True):
last_dir = root.split('/')[-1]
pre_last_dir = root.split('/')[-2]
last_dir = root.split('\\')[-1]
pre_last_dir = root.split('\\')[-2]
if pre_last_dir not in parents_id.keys():
pre_last_dir = []
else:
Expand Down Expand Up @@ -259,9 +257,9 @@ def main():
# so now in can be upload from top to down of tree
upload_folders = sorted(upload_folders, key=by_lines)

# Here we upload new (abcent on Drive) folders
# Here we upload new (absent on Drive) folders
for folder_dir in upload_folders:
var = os.path.join(full_path.split(os.path.sep)[0:-1]) + os.path.sep
var = (os.path.sep).join(full_path.split(os.path.sep)[0:-1]) + os.path.sep
variable = var + folder_dir
last_dir = folder_dir.split(os.path.sep)[-1]
pre_last_dir = folder_dir.split(os.path.sep)[-2]
Expand Down Expand Up @@ -383,7 +381,7 @@ def main():
var = (os.path.sep).join(full_path.split(
os.path.sep)[0:-1]) + os.path.sep
variable = var + folder_dir
last_dir = folder_dir.split('/')[-1]
last_dir = folder_dir.split('\\')[-1]
folder_id = parents_id[last_dir]
service.files().delete(fileId=folder_id).execute()

Expand Down