Commit c6bc490c authored by Маркин Юрий Витальевич's avatar Маркин Юрий Витальевич
Browse files

Do not share with public link

parent d7cbee0f
......@@ -4,6 +4,7 @@ import sys
from .file2getbox import GetboxUploader
def main():
"""Console script for file2getbox."""
# parser = argparse.ArgumentParser()
......@@ -16,7 +17,6 @@ def main():
getbox_folder = sys.argv[2]
gu = GetboxUploader()
gu.process(filename, getbox_folder)
pass
return 0
......
"""Main module."""
import os
import sys
import socket
import datetime
import configparser
import six
from six.moves.urllib import parse
import os
import owncloud
......@@ -15,24 +9,24 @@ class GetboxUploader:
'''
All my facebook operations
'''
def __init__(self):
def get_config():
config = configparser.ConfigParser()
for configfile in [
os.path.expanduser('~/keys/ispras/ispras.ini' % vars())
]:
os.path.expanduser('~/keys/ispras/ispras.ini' % vars())]:
try:
config.read(configfile)
break
except Exception:
pass
return config
return config
self.config = get_config()
uname = self.config['default']['UserName'].strip('"')
password = self.config['default']['Password'].strip('"')
oc = self.occlient = owncloud.Client('https://nextcloud.ispras.ru/')
oc = self.occlient = owncloud.Client('https://nextcloud.ispras.ru/')
oc.login(uname, password)
pass
......@@ -41,33 +35,29 @@ class GetboxUploader:
print(f'Looks like {filename} and {getbox_folder} not exists as local file')
if not os.path.exists(filename) and os.path.exists(getbox_folder):
# Missed filename and getbox_folder, need swap
# Missed filename and getbox_folder, need swap
filename, getbox_folder = getbox_folder, filename
print(f'Looks like you want put «{filename}» into «{getbox_folder}»')
filename_ = os.path.split(filename)[1]
ocpath = os.path.join(getbox_folder, filename_).replace('\\', '/')
ocpath_terms = getbox_folder.split('/')[1:]
try:
print(ocpath_terms)
print(filename, "->", ocpath)
for i_ in range(1, len(ocpath_terms)+1):
for i_ in range(1, len(ocpath_terms) + 1):
predir = "/".join(ocpath_terms[:i_])
# print(f"trying to create dir {predir}")
try:
self.occlient.mkdir(predir)
except:
pass
pass
self.occlient.put_file(ocpath, filename)
link_info = self.occlient.share_file_with_link(ocpath)
print(link_info.get_link())
# link_info = self.occlient.share_file_with_link(ocpath)
# print(link_info.get_link())
except Exception as ex_:
# При публикации в шаред папку где-то падает в глубинах по #500, но вроде при этом все ОК.
# Надо контроль, что загрузилось, делать отдельно. хешсуммы там.64
# pass
# pass
raise ex_
# self.occlient.put_file(filename, filepath)
pass
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment