def get_production_order_manifest_set(serialno): workspace = temp_fs.makeopendir(get_tempname()) children = serialnos.get_child_serialnos(sno=serialno) manifests = [] for child in children: files = [] am = docstore.get_docs_list_for_sno_doctype(serialno=child, doctype='ASSEMBLY MANIFEST') if len(am) == 1: uam = am[0] copyfile(uam.fs, uam.path, workspace, uam.filename, overwrite=True) files = [workspace.getsyspath(uam.filename)] elif len(am) > 1: raise ValueError( "Found {0} manifests for {2}".format(len(am), child) ) dms = docstore.get_docs_list_for_sno_doctype( serialno=child, doctype='DELTA ASSEMBLY MANIFEST' ) if len(dms): for dm in dms: copyfile(dm.fs, dm.path, workspace, dm.filename, overwrite=True) files.append(workspace.getsyspath(dm.filename)) if len(files) > 1: wdmfile = merge_pdf( files, os.path.join(workspace.getsyspath('/'), os.path.splitext(am[0].filename)[0] + '-wdm.pdf'), remove_sources=True ) manifests.append(wdmfile) elif len(files) == 1: manifests.append(files[0]) if len(manifests): output = merge_pdf( manifests, os.path.join(workspace.getsyspath('/'), serialno + '.pdf'), remove_sources=True ) return output return None
def get_production_order_manifest_set(serialno): workspace = temp_fs.makeopendir(get_tempname()) children = serialnos.get_child_serialnos(sno=serialno) manifests = [] for child in children: files = [] am = docstore.get_docs_list_for_sno_doctype( serialno=child, doctype='ASSEMBLY MANIFEST') if len(am) == 1: uam = am[0] copyfile(uam.fs, uam.path, workspace, uam.filename, overwrite=True) files = [workspace.getsyspath(uam.filename)] elif len(am) > 1: raise ValueError("Found {0} manifests for {2}".format( len(am), child)) dms = docstore.get_docs_list_for_sno_doctype( serialno=child, doctype='DELTA ASSEMBLY MANIFEST') if len(dms): for dm in dms: copyfile(dm.fs, dm.path, workspace, dm.filename, overwrite=True) files.append(workspace.getsyspath(dm.filename)) if len(files) > 1: wdmfile = merge_pdf( files, os.path.join(workspace.getsyspath('/'), os.path.splitext(am[0].filename)[0] + '-wdm.pdf'), remove_sources=True) manifests.append(wdmfile) elif len(files) == 1: manifests.append(files[0]) if len(manifests): output = merge_pdf(manifests, os.path.join(workspace.getsyspath('/'), serialno + '.pdf'), remove_sources=True) return output return None
from docstore import refdoc_fs from tendril.boms import electronics as boms_electronics from tendril.boms import outputbase as boms_outputbase from tendril.gedaif import conffile from tendril.gedaif import gerberfiles from tendril.gedaif import gschem from tendril.gedaif import pcb from tendril.gedaif import projfile from tendril.utils import fsutils from tendril.utils import log from tendril.utils.config import PROJECTS_ROOT from tendril.utils.fsutils import temp_fs from tendril.utils.files import pdf from tendril.utils.files import yml as yaml workspace_fs = temp_fs.makeopendir('workspace_gpd') logger = log.get_logger(__name__, log.DEFAULT) def get_project_doc_folder(projectfolder): # TODO replace with doc_folder from configs? projectfolder = os.path.realpath(projectfolder) projectfolder = os.path.relpath(projectfolder, PROJECTS_ROOT) pth = path.join(projectfolder, 'doc') try: if not refdoc_fs.exists(pth): refdoc_fs.makedir(pth, recursive=True) if not refdoc_fs.exists(path.join(pth, 'confdocs')): refdoc_fs.makedir(path.join(pth, 'confdocs'), recursive=True) except PermissionDeniedError: logger.warning("Permission denied when creating folder for " +
from flask_user import login_required from tendril.utils.config import DOCSTORE_ROOT from tendril.utils.config import DOCSTORE_PREFIX from tendril.utils.config import DOCUMENT_WALLET_ROOT from tendril.utils.config import DOCUMENT_WALLET_PREFIX from tendril.utils.config import REFDOC_ROOT from tendril.utils.config import REFDOC_PREFIX from tendril.utils.fsutils import temp_fs from tendril.dox.docstore import refdoc_fs from tendril.dox.docstore import docstore_fs from tendril.dox.wallet import wallet_fs expose = Blueprint('expose', __name__) temp_expose_fs = temp_fs.makeopendir('expose') def get_sendable_path(fspath, fs, fs_root): if isinstance(fs, OSFS): path = os.path.join(fs_root, fspath) else: path = temp_expose_fs.getsyspath(fspath) if not temp_expose_fs.exists(fspath): temp_expose_fs.makedir( os.path.split(fspath)[0], recursive=True, allow_recreate=True ) copyfile( fs, fspath,
from flask_user import login_required from tendril.utils.config import DOCSTORE_ROOT from tendril.utils.config import DOCSTORE_PREFIX from tendril.utils.config import DOCUMENT_WALLET_ROOT from tendril.utils.config import DOCUMENT_WALLET_PREFIX from tendril.utils.config import REFDOC_ROOT from tendril.utils.config import REFDOC_PREFIX from tendril.utils.fsutils import temp_fs from tendril.dox.docstore import refdoc_fs from tendril.dox.docstore import docstore_fs from tendril.dox.wallet import wallet_fs expose = Blueprint('expose', __name__) temp_expose_fs = temp_fs.makeopendir('expose') def get_sendable_path(fspath, fs, fs_root): if isinstance(fs, OSFS): path = os.path.join(fs_root, fspath) else: path = temp_expose_fs.getsyspath(fspath) if not temp_expose_fs.exists(fspath): temp_expose_fs.makedir(os.path.split(fspath)[0], recursive=True, allow_recreate=True) copyfile(fs, fspath, temp_expose_fs, fspath) return path
from fs.opener import fsopendir from fs.utils import copyfile from fs import path from fs.errors import NoSysPathError from fs.rpcfs import RPCFS from fs.rpcfs import RemoteConnectionError from tendril.utils.config import INSTANCE_ROOT from tendril.utils.config import DOCUMENT_WALLET from tendril.utils.config import DOCUMENT_WALLET_ROOT from tendril.utils.fsutils import temp_fs from tendril.utils import log logger = log.get_logger(__name__, log.DEFAULT) wallet_temp_fs = temp_fs.makeopendir('wallet') def _wallet_init(): if DOCUMENT_WALLET_ROOT.startswith('rpc://'): try: l_wallet_fs = RPCFS('http://' + DOCUMENT_WALLET_ROOT[len('rpc://'):]) except RemoteConnectionError: lpath = os.path.join(INSTANCE_ROOT, 'wallet') logger.error('Could not connect to configured DOCUMENT_WALLET. ' 'Using {0}.'.format(lpath)) l_wallet_fs = fsopendir(lpath, create_dir=True) else: l_wallet_fs = fsopendir(DOCUMENT_WALLET_ROOT, create_dir=True) return l_wallet_fs
from tendril.boms import electronics as boms_electronics from tendril.boms import outputbase as boms_outputbase from tendril.gedaif import conffile from tendril.gedaif import gerberfiles from tendril.gedaif import gschem from tendril.gedaif import pcb from tendril.gedaif import projfile from tendril.utils import fsutils from tendril.utils import log from tendril.utils.config import PROJECTS_ROOT from tendril.utils.fsutils import temp_fs from tendril.utils.files import pdf from tendril.utils.files import yml as yaml workspace_fs = temp_fs.makeopendir('workspace_gpd') logger = log.get_logger(__name__, log.DEFAULT) def get_project_doc_folder(projectfolder): # TODO replace with doc_folder from configs? projectfolder = os.path.realpath(projectfolder) projectfolder = os.path.relpath(projectfolder, PROJECTS_ROOT) pth = path.join(projectfolder, 'doc') try: if not refdoc_fs.exists(pth): refdoc_fs.makedir(pth, recursive=True) if not refdoc_fs.exists(path.join(pth, 'confdocs')): refdoc_fs.makedir(path.join(pth, 'confdocs'), recursive=True) except PermissionDeniedError: logger.warning(