cleanup: pep8
This commit is contained in:
@@ -189,7 +189,6 @@ class bam_session:
|
||||
os.path.join(session_rootdir, ".bam_tmp.zip"),
|
||||
}
|
||||
|
||||
|
||||
with open(os.path.join(session_rootdir, ".bam_paths_uuid.json")) as f:
|
||||
import json
|
||||
paths_uuid = json.load(f)
|
||||
@@ -293,7 +292,6 @@ class bam_commands:
|
||||
|
||||
print("Project %r initialized" % proj_dirname)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def create(session_name):
|
||||
import os
|
||||
@@ -382,7 +380,7 @@ class bam_commands:
|
||||
|
||||
tot_size = 0
|
||||
for chunk in r.iter_content(chunk_size=1024):
|
||||
if chunk: # filter out keep-alive new chunks
|
||||
if chunk: # filter out keep-alive new chunks
|
||||
tot_size += len(chunk)
|
||||
f.write(chunk)
|
||||
f.flush()
|
||||
@@ -404,7 +402,6 @@ class bam_commands:
|
||||
|
||||
@staticmethod
|
||||
def commit(paths, message):
|
||||
import sys
|
||||
import os
|
||||
import requests
|
||||
|
||||
@@ -439,11 +436,9 @@ class bam_commands:
|
||||
with open(os.path.join(session_rootdir, ".bam_paths_uuid.json")) as f:
|
||||
paths_uuid = json.load(f)
|
||||
|
||||
|
||||
with open(os.path.join(session_rootdir, ".bam_deps_remap.json")) as f:
|
||||
deps_remap = json.load(f)
|
||||
|
||||
|
||||
paths_add = {}
|
||||
paths_modified = {}
|
||||
paths_remove = {}
|
||||
@@ -458,7 +453,6 @@ class bam_commands:
|
||||
print("Nothing to commit!")
|
||||
return
|
||||
|
||||
|
||||
for fn_rel, fn_abs in list(paths_modified.items()):
|
||||
# we may want to be more clever here
|
||||
deps = deps_remap.get(fn_rel)
|
||||
@@ -555,7 +549,6 @@ class bam_commands:
|
||||
# TODO(cam)
|
||||
# if all goes well, rewrite sha1's
|
||||
|
||||
|
||||
@staticmethod
|
||||
def status(paths):
|
||||
# TODO(cam) multiple paths
|
||||
@@ -565,7 +558,6 @@ class bam_commands:
|
||||
session_rootdir = bam_config.find_sessiondir(path, abort=True)
|
||||
print(session_rootdir)
|
||||
|
||||
|
||||
paths_add = {}
|
||||
paths_modified = {}
|
||||
paths_remove = {}
|
||||
@@ -623,7 +615,6 @@ class bam_commands:
|
||||
if file_type != "dir":
|
||||
print(" %s" % name_short)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def deps(paths, recursive=False):
|
||||
import blendfile_path_walker
|
||||
@@ -717,7 +708,7 @@ def create_argparse_checkout(subparsers):
|
||||
help="Path to checkout on the server",
|
||||
)
|
||||
subparse.add_argument(
|
||||
"-o", "--output",dest="output", type=str, metavar='DIRNAME',
|
||||
"-o", "--output", dest="output", type=str, metavar='DIRNAME',
|
||||
help="Local name to checkout the session into (optional, falls back to path name)",
|
||||
)
|
||||
subparse.set_defaults(func=subcommand_checkout_cb)
|
||||
|
@@ -7,7 +7,6 @@ import os
|
||||
MODULE_DIR = os.path.dirname(__file__)
|
||||
|
||||
with open(os.path.join(MODULE_DIR, 'config.json'), 'r') as config:
|
||||
import json
|
||||
config = json.load(config)
|
||||
|
||||
|
||||
@@ -29,7 +28,7 @@ def request_url(path):
|
||||
|
||||
# print (r.json())
|
||||
# with open(local_filename, 'wb') as f:
|
||||
# for chunk in r.iter_content(chunk_size=1024):
|
||||
# for chunk in r.iter_content(chunk_size=1024):
|
||||
# if chunk: # filter out keep-alive new chunks
|
||||
# f.write(chunk)
|
||||
# f.flush()
|
||||
@@ -39,7 +38,7 @@ def request_url(path):
|
||||
# with open(filepath) as fh:
|
||||
# mydata = fh.read()
|
||||
# response = requests.put('https://api.elasticemail.com/attachments/upload',
|
||||
# data=mydata,
|
||||
# data=mydata,
|
||||
# auth=('omer', 'b01ad0ce'),
|
||||
# headers={'content-type':'text/plain'},
|
||||
# params={'file': filepath}
|
||||
@@ -55,12 +54,11 @@ payload = {
|
||||
}
|
||||
|
||||
files = {'file': open('buck.mp4', 'rb')}
|
||||
#files = {'name': ('filename', (open('mytest.txt', 'rb')))}
|
||||
# files = {'name': ('filename', (open('mytest.txt', 'rb')))}
|
||||
|
||||
r = requests.put(request_url('/file'),
|
||||
r = requests.put(request_url('/file'),
|
||||
params=payload,
|
||||
auth=('bam', 'bam'),
|
||||
files=files)
|
||||
|
||||
print(r.text)
|
||||
|
||||
|
@@ -184,7 +184,8 @@ class Application(tk.Frame):
|
||||
but.grid(row=row, column=0)
|
||||
self.grid_members.append(but)
|
||||
|
||||
def fn(idname=name_short, but_path=but_path): exec_path_dir(idname, but_path)
|
||||
def fn(idname=name_short, but_path=but_path):
|
||||
exec_path_dir(idname, but_path)
|
||||
|
||||
but = tk.Button(self.frame, text=name_short + "/", fg="green", command=fn)
|
||||
but.grid(row=row, column=1, sticky="nw")
|
||||
@@ -213,7 +214,9 @@ class Application(tk.Frame):
|
||||
if item_type == "file":
|
||||
but = tk.Label(self.frame, text="(b)", width=3, borderwidth="1", relief="solid")
|
||||
but.grid(row=row, column=0)
|
||||
def fn(idname=name_short): exec_path_blendfile(idname)
|
||||
|
||||
def fn(idname=name_short):
|
||||
exec_path_blendfile(idname)
|
||||
self.grid_members.append(but)
|
||||
|
||||
but = tk.Button(self.frame, text=name_short, fg="blue", command=fn)
|
||||
@@ -231,4 +234,3 @@ root = tk.Tk()
|
||||
app = Application(root).pack(side="top", fill="both", expand=True)
|
||||
root.title("BAM")
|
||||
root.mainloop()
|
||||
|
||||
|
@@ -55,4 +55,3 @@ def sha1_from_file(fn, block_size=1 << 20):
|
||||
break
|
||||
sha1.update(data)
|
||||
return sha1.hexdigest()
|
||||
|
||||
|
@@ -245,7 +245,6 @@ def pack(blendfile_src, blendfile_dst, mode='FILE',
|
||||
zip_handle.write(src.decode('utf-8'),
|
||||
arcname=os.path.relpath(dst, base_dir_dst).decode('utf-8'))
|
||||
|
||||
|
||||
yield report(" %s: %r\n" % (colorize("written", color='green'), blendfile_dst))
|
||||
else:
|
||||
raise Exception("%s not a known mode" % mode)
|
||||
@@ -331,4 +330,3 @@ def main():
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
@@ -56,7 +56,7 @@ def create_from_files(deps):
|
||||
for f_abs in iter_files_blend(dirname):
|
||||
if f_abs.endswith(".png"):
|
||||
f_rel = bpy.path.relpath(f_abs)
|
||||
image = bpy.data.images.load(f)
|
||||
image = bpy.data.images.load(f_rel)
|
||||
image.use_fake_user = True
|
||||
deps.append(f_abs)
|
||||
|
||||
@@ -96,4 +96,3 @@ if __name__ == "__main__":
|
||||
|
||||
import sys
|
||||
sys.exit(returncode)
|
||||
|
||||
|
@@ -247,7 +247,6 @@ def bam_run(argv, cwd=None):
|
||||
import shlex
|
||||
sys.stdout.write("bam %s\n" % " ".join([shlex.quote(c) for c in argv]))
|
||||
|
||||
|
||||
# input('press_key!:')
|
||||
|
||||
with StdIO() as fakeio:
|
||||
@@ -299,19 +298,20 @@ def blendfile_template_create(blendfile, create_id, deps):
|
||||
returncode_test = 123
|
||||
blendfile_deps_json = os.path.join(TEMP_LOCAL, "blend_template_deps.json")
|
||||
os.makedirs(os.path.dirname(blendfile), exist_ok=True)
|
||||
stdout, stderr, returncode = run(
|
||||
("blender",
|
||||
"--background",
|
||||
"--factory-startup",
|
||||
"-noaudio",
|
||||
"--python",
|
||||
os.path.join(CURRENT_DIR, "blendfile_templates.py"),
|
||||
"--",
|
||||
blendfile,
|
||||
blendfile_deps_json,
|
||||
create_id,
|
||||
str(returncode_test),
|
||||
))
|
||||
cmd = (
|
||||
"blender",
|
||||
"--background",
|
||||
"--factory-startup",
|
||||
"-noaudio",
|
||||
"--python",
|
||||
os.path.join(CURRENT_DIR, "blendfile_templates.py"),
|
||||
"--",
|
||||
blendfile,
|
||||
blendfile_deps_json,
|
||||
create_id,
|
||||
str(returncode_test),
|
||||
)
|
||||
stdout, stderr, returncode = run(cmd)
|
||||
|
||||
if os.path.exists(blendfile_deps_json):
|
||||
import json
|
||||
@@ -577,6 +577,7 @@ class BamListTest(BamSessionTestCase):
|
||||
|
||||
import json
|
||||
ret = json.loads(stdout)
|
||||
self.assertEqual(2, len(ret))
|
||||
|
||||
|
||||
class BamCommitTest(BamSessionTestCase):
|
||||
@@ -645,8 +646,7 @@ class BamBlendTest(BamSimpleTestCase):
|
||||
yield filepath
|
||||
|
||||
for create_id, create_fn in blendfile_templates.__dict__.items():
|
||||
if (create_id.startswith("create_") and
|
||||
create_fn.__class__.__name__ == "function"):
|
||||
if (create_id.startswith("create_") and create_fn.__class__.__name__ == "function"):
|
||||
|
||||
os.makedirs(TEMP_SESSION)
|
||||
|
||||
@@ -694,7 +694,6 @@ class BamDeleteTest(BamSessionTestCase):
|
||||
def test_delete(self):
|
||||
session_name = "mysession"
|
||||
file_name = "testfile.blend"
|
||||
file_data = b"hello world!\n"
|
||||
proj_path, session_path = self.init_session(session_name)
|
||||
|
||||
# now do a real commit
|
||||
@@ -706,7 +705,7 @@ class BamDeleteTest(BamSessionTestCase):
|
||||
stdout, stderr = bam_run(["commit", "-m", "tests message"], session_path)
|
||||
self.assertEqual("", stderr)
|
||||
|
||||
# remove the path
|
||||
# remove the path
|
||||
shutil.rmtree(session_path)
|
||||
del session_path
|
||||
|
||||
@@ -717,7 +716,6 @@ class BamDeleteTest(BamSessionTestCase):
|
||||
stdout, stderr = bam_run(["checkout", file_name, "--output", "new_out"], proj_path)
|
||||
self.assertEqual("", stderr)
|
||||
|
||||
|
||||
# now delete the file we just checked out
|
||||
session_path = os.path.join(proj_path, "new_out")
|
||||
os.remove(os.path.join(session_path, file_name))
|
||||
@@ -740,4 +738,3 @@ if __name__ == '__main__':
|
||||
data = global_setup()
|
||||
unittest.main(exit=False)
|
||||
global_teardown(data)
|
||||
|
||||
|
@@ -117,7 +117,6 @@ class DirectoryAPI(Resource):
|
||||
path_root_abs = os.path.join(path_root_abs, path)
|
||||
parent_path = os.pardir
|
||||
|
||||
|
||||
if not os.path.isdir(path_root_abs):
|
||||
return jsonify(message="Path is not a directory %r" % path_root_abs)
|
||||
|
||||
@@ -138,7 +137,7 @@ class DirectoryAPI(Resource):
|
||||
}
|
||||
|
||||
return jsonify(project_files)
|
||||
#return {'message': 'Display files list'}
|
||||
# return {'message': 'Display files list'}
|
||||
|
||||
|
||||
class FileAPI(Resource):
|
||||
@@ -218,7 +217,6 @@ class FileAPI(Resource):
|
||||
yield report("%s: %r\n" % (colorize("failed to extract", color='red'), filepath))
|
||||
return
|
||||
|
||||
|
||||
with open(filepath_zip, 'rb') as f:
|
||||
f.seek(0, os.SEEK_END)
|
||||
f_size = f.tell()
|
||||
@@ -246,8 +244,12 @@ class FileAPI(Resource):
|
||||
file = request.files['file']
|
||||
|
||||
# Get the value of the first (and only) result for the specified project setting
|
||||
svn_password = next((setting.value for setting in project.settings if setting.name == 'svn_password'))
|
||||
svn_default_user = next((setting.value for setting in project.settings if setting.name == 'svn_default_user'))
|
||||
svn_password = next((setting.value
|
||||
for setting in project.settings
|
||||
if setting.name == 'svn_password'))
|
||||
svn_default_user = next((setting.value
|
||||
for setting in project.settings
|
||||
if setting.name == 'svn_default_user'))
|
||||
|
||||
# We get the actual username from the http headers
|
||||
svn_user = auth.username()
|
||||
@@ -310,7 +312,7 @@ class FileAPI(Resource):
|
||||
# We add each unversioned file to SVN
|
||||
if item_status == 'unversioned':
|
||||
result = local_client.run_command('add',
|
||||
[file_path,])
|
||||
[file_path, ])
|
||||
|
||||
with open(os.path.join(extract_tmp_dir, '.bam_paths_ops.json'), 'r') as path_ops:
|
||||
path_ops = json.load(path_ops)
|
||||
@@ -322,18 +324,16 @@ class FileAPI(Resource):
|
||||
file_path_abs = os.path.join(project.repository_path, file_path)
|
||||
assert(os.path.exists(file_path_abs))
|
||||
result = local_client.run_command('rm',
|
||||
[file_path_abs,])
|
||||
|
||||
[file_path_abs, ])
|
||||
|
||||
# Commit command
|
||||
result = local_client.run_command('commit',
|
||||
[local_client.info()['entry_path'],
|
||||
[local_client.info()['entry_path'],
|
||||
'--message', arguments['message'],
|
||||
'--username', svn_user,
|
||||
'--password', svn_password],
|
||||
combine=True)
|
||||
|
||||
|
||||
return jsonify(message=result)
|
||||
else:
|
||||
return jsonify(message='File not allowed')
|
||||
@@ -405,8 +405,6 @@ class FileAPI(Resource):
|
||||
del write_dict_as_json
|
||||
# done writing json!
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def allowed_file(filename):
|
||||
return '.' in filename and \
|
||||
@@ -415,4 +413,3 @@ class FileAPI(Resource):
|
||||
|
||||
api.add_resource(DirectoryAPI, '/<project_name>/file_list', endpoint='file_list')
|
||||
api.add_resource(FileAPI, '/<project_name>/file', endpoint='file')
|
||||
|
||||
|
@@ -27,15 +27,15 @@ def _list_items(view, context, model, name):
|
||||
return Markup(
|
||||
'<div class="select2-container-multi">'
|
||||
'<ul class="select2-choices" style="border:0;cursor:default;background:none;">%s</ul></div>' % (
|
||||
''.join( ['<li class="select2-search-choice" style="padding:3px 5px;">'
|
||||
'<div>'+item.name+'</div></li>' for item in getattr(model,name)] )))
|
||||
''.join(['<li class="select2-search-choice" style="padding:3px 5px;">'
|
||||
'<div>' + item.name + '</div></li>' for item in getattr(model, name)] )))
|
||||
|
||||
|
||||
def _list_thumbnail(view, context, model, name):
|
||||
if not getattr(model,name): #model.name only does not work because name is a string
|
||||
if not getattr(model,name): # model.name only does not work because name is a string
|
||||
return ''
|
||||
return ''
|
||||
# return Markup('<img src="%s">' % url_for('static',
|
||||
# return Markup('<img src="%s">' % url_for('static',
|
||||
# filename=thumb.thumbnail(getattr(model,name), '50x50', crop='fit')))
|
||||
|
||||
# Create directory for file fields to use
|
||||
@@ -81,19 +81,20 @@ class CKTextAreaField(fields.TextAreaField):
|
||||
class CustomModelView(ModelView):
|
||||
def is_accessible(self):
|
||||
return True
|
||||
#return login.current_user.has_role('admin')
|
||||
# return login.current_user.has_role('admin')
|
||||
|
||||
|
||||
class CustomBaseView(BaseView):
|
||||
def is_accessible(self):
|
||||
return True
|
||||
#return login.current_user.has_role('admin')
|
||||
# return login.current_user.has_role('admin')
|
||||
|
||||
|
||||
# Create customized index view class that handles login & registration
|
||||
class CustomAdminIndexView(admin.AdminIndexView):
|
||||
def is_accessible(self):
|
||||
return True
|
||||
#return login.current_user.has_role('admin')
|
||||
# return login.current_user.has_role('admin')
|
||||
|
||||
@expose('/')
|
||||
def index(self):
|
||||
@@ -107,9 +108,8 @@ class CustomAdminIndexView(admin.AdminIndexView):
|
||||
|
||||
# Create admin
|
||||
backend = Admin(
|
||||
app,
|
||||
'BAM',
|
||||
index_view=CustomAdminIndexView(),
|
||||
base_template='admin/layout_admin.html'
|
||||
)
|
||||
|
||||
app,
|
||||
"BAM",
|
||||
index_view=CustomAdminIndexView(),
|
||||
base_template="admin/layout_admin.html"
|
||||
)
|
||||
|
@@ -10,16 +10,16 @@ from application.modules.admin import _list_thumbnail
|
||||
class ProjectView(CustomModelView):
|
||||
column_searchable_list = ('name',)
|
||||
column_list = ('name', 'picture', 'creation_date')
|
||||
#column_formatters = { 'picture': _list_thumbnail }
|
||||
#form_extra_fields = {'picture': image_upload_field('Header')}
|
||||
# column_formatters = { 'picture': _list_thumbnail }
|
||||
# form_extra_fields = {'picture': image_upload_field('Header')}
|
||||
form_overrides = dict(
|
||||
status=SelectField,
|
||||
)
|
||||
form_args = dict(
|
||||
status=dict(
|
||||
label='Status',
|
||||
label='Status',
|
||||
choices=[
|
||||
('active', 'Active'),
|
||||
('active', 'Active'),
|
||||
('inactive', 'Inactive'),
|
||||
('canceled', 'Canceled')
|
||||
]),
|
||||
|
@@ -9,7 +9,7 @@ class Project(db.Model):
|
||||
upload_path = db.Column(db.Text, nullable=False)
|
||||
picture = db.Column(db.String(80))
|
||||
creation_date = db.Column(db.DateTime(), default=datetime.datetime.now)
|
||||
status = db.Column(db.String(80)) #active #inactive
|
||||
status = db.Column(db.String(80)) # active #inactive
|
||||
|
||||
settings = db.relationship('ProjectSetting', backref='project')
|
||||
|
||||
|
@@ -70,4 +70,3 @@ if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
|
||||
|
Reference in New Issue
Block a user