Ejemplo n.º 1
0
def _save_file(path_file, path_save, name_zip_):
    try:
        _makeDir(path_save)

        save_date = _dateNowFormat(_save_tag_fileUpload)
        name_save = '%s%s' % (save_date, _basename(path_file))
        file_save = _pathJoin([path_save, name_save])
        name_zip_ = '%s-bak.zip' % name_zip_
        file_zip_ = _pathJoin([path_save, name_zip_])

        _fileMove(path_file, file_save)
    except:
        pass

    with zipfile.ZipFile(file_zip_, 'a') as zip:

        try:
            zip.write(file_save, _basename(file_save))
        except:
            pass
        finally:
            zip.close()

        _fileRemove(file_save)
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-
__author__ = 'zappyk'

import argparse, configparser

from lib_zappyk._log     import _log
from lib_zappyk._os_file import _pathAbs, _pathJoin, _fileExist, _pathSep, _pathExpanduser

from MergeTwoCsv2One               import *
from MergeTwoCsv2One.src.constants import *

_project_     = get_project()
_description_ = get_description()

name_conf = '%s-config.ini' % _project_
path_conf = _pathAbs(_pathJoin(['.']))
file_conf = _pathAbs(_pathJoin([path_conf, name_conf]))

name_logs = '%s-logger.ini' % _project_
path_logs = _pathAbs(_pathJoin(['.']))
file_logs = _pathAbs(_pathJoin([path_logs, name_logs]))

default_stdin   = CHAR_STD_INOUT
default_stdout  = CHAR_STD_INOUT
default_typein  = TYPE_IN_mmam
default_typeout = TYPE_OUT_csv
default_typeout = None
list_typein     = [TYPE_IN_mmam]
list_typeout    = [TYPE_OUT_csv,TYPE_OUT_xls]

###############################################################################
Ejemplo n.º 3
0
filename           = args.sht_filename       if args.sht_filename       is not None else filename
file_key           = args.sht_file_key       if args.sht_file_key       is not None else file_key
file_url           = args.sht_file_url       if args.sht_file_url       is not None else file_url
wks_name           = args.wks_name           if args.wks_name           is not None else wks_name
wks_rows_resize    = args.wks_rows_resize    if args.wks_rows_resize    is not None else False
wks_cell_update    = args.wks_cell_update    if args.wks_cell_update    is not None else False
wks_rows_resize    = False                   if wks_cell_update                     else wks_rows_resize

action_write_wait  = args.action_write_wait  if args.action_write_wait  is not None else False
second_write_wait  = args.second_write_wait  if args.second_write_wait  is not None else None

wks_read   = True if args.action == 'r' else False
wks_write  = True if args.action == 'w' else False
wks_update = True if args.action == 'u' else False

servicej = _pathJoin([savejson, servicej]) if servicej is not None else servicej
accountj = _pathJoin([savejson, accountj]) if accountj is not None else accountj
tknstore = _pathJoin([savejson, tknstore]) if tknstore is not None else tknstore

login_credential_servicej = False if servicej is None else True
login_credential_accountj = False if accountj is None else not(login_credential_servicej)
login_credential          = True  if (servicej or accountj) else False

#csv_delimiter     = ','               if csv_delimiter      is None else csv_delimiter
#csv_quotechar     = '"'               if csv_quotechar      is None else csv_quotechar
#csv_quoting       = csv.QUOTE_MINIMAL if csv_quoting        is None else csv_quoting
csv_quoting        = csv.QUOTE_NONE    if csv_quoting        is None else csv_quoting
#csv_lineterminator= "\r\n"            if csv_lineterminator is None else csv_lineterminator

if second_write_wait is not None:
    (SLEEP_MULTIPLE_LINE
Ejemplo n.º 4
0
    else:
        _makeDir(path_split)
    return (path_split)


###############################################################################
if __name__ == '__main__':
    args = _getargs()

    base_sheet = args.base_sheet
    file_input = args.file_input
    #CZ#archiveset = args.archive_set
    tag_output = args.tag_output
    nameoutput = (tag_output, _basename(file_input))
    pathoutput = (_basepath(file_input), ''.join(nameoutput))
    fileoutput = _pathJoin(pathoutput)

    name_input = _basename(file_input)

    try:
        logs.info('[%s]' % _pathCurrent())
        logs.info('Duplicate Worksheet "%s" to list sheetname %s' %
                  (base_sheet, _duplicates_))
        logs.info('Open file "%s" for duplicate:' % file_input)
        (workbook, xlsx_ext) = open_file_input(file_input)

#CZ#except ExceptionFileInputNotParsed as e:
#CZ#    logs.error(str(e))
    except Exception as e:
        logs.error(str(e))
Ejemplo n.º 5
0
    #_______________________________________________________________________________________________________________________________________________________________
    #                                                                                                                                                              #
    # curl --digest -u "url_username:url_password" -F "file=@path_file" -H "X-BOS-MFT=1" -H "X-BOS-MFT-CLIENTID=flow_name" url_address                             #
    # curl          -u "url_username:url_password" -F "file=@path_file" -H "X-BOS-MFT=1" -H "X-BOS-MFT-CLIENTID=flow_name" url_address                             #
    #______________________________________________________________________________________________________________________________________________________________#
    #                                                                                                                                                              #
    # curl          -u "%MFT_auth%"      -F "file=@%MFT_file%"     -H "X-BOS-MFT:1" -H "X-BOS-MFT-CLIENTID:%MFT_flow%" "%MFT_endp%"                                #
    # curl          -u "tstmft0:tstmft0" -F "file=@C:\tmp\TST.txt" -H "X-BOS-MFT:1" -H "X-BOS-MFT-CLIENTID:TSTMFT0"    "http://apps.payroll.it/bos-mft-server/mft" #
    #______________________________________________________________________________________________________________________________________________________________#

    exitcode = None
    messages = None

    move_file = None
    send_file = _pathJoin([
        path_save, ('%s_send2payroll_%s' % (flow_name, _basename(path_file)))
    ])

    if _fileExist(send_file):
        messages = _message_check % send_file
        logs.info(messages)

        move_file = send_file
    else:

        if _fileExist(path_file):
            try:
                #CZ#messages = _message_check % path_file ; logs.info(messages)

                _fileMove(path_file, send_file)
                move_file = path_file
Ejemplo n.º 6
0
        logs.info('_%s_' % ('_' * len(path)))
        logs.info('|%s|' % path)
        logs.info('\ttitle: %s' % title[name])
        logs.info('\tquery: %s' % query[name])
    logs.error('Done')

sql_section = None if sql_query is None else sql_section

if sql_section is None:
    logs.error('Query [%s] not found!' % run_query)
else:
    logs.info('title: %s' % sql_title)
#CZ#logs.info('query: %s' % sql_query)

####################
file_input = _pathJoin([_pathCurrent(), sql_title])
type_input = run_query
####################

run_gui = True if sys.platform == 'win32' else run_gui
run_gui = False if run_cmd else run_gui

name_input = _basenameNotExt(file_input)
exte_output = _basenameGetExt(file_output)
type_output = TYPE_OUT_csv if (type_output is None) and (
    exte_output[1:] == TYPE_OUT_csv) else type_output
type_output = TYPE_OUT_xls if (type_output is None) and (
    exte_output[1:] == TYPE_OUT_xls) else type_output

file_output_csv = '.'.join([_basenameFullPathNotExt(file_input), TYPE_OUT_csv])
file_output_xls = '.'.join([_basenameFullPathNotExt(file_input), TYPE_OUT_xls])