Python - whats the next command?

Hello!

I’m trying to run a script with Python (I think).

It runs well. However, at the end, I get this:

I suppose its not so strange since the script hasnt made the .ti3 file… however, the developer has provided the recipe for how to sort this (I think), but I dont understand what do do:

As far as I can tell this should solve it… but I dont know which of that information I should use and how to apply it… any suggestions?

Cheers
Peter

Perhaps, it would be helpful if you included the if statement (and relevant lines above) corresponding to the else where the error message is thrown.

If you search for the following keywords:

  • script_pth
  • temp_file
  • outfile
  • icc_file

You can somehow conclude where a file should be and how it should roughly look like.

The problem with this approach is, that this is extremely tedious to do and you can still completely fail.

I suggest, if you are using a program that is hard to use, then read the whole documentation written by the developer very thoroughly to understand what exactly to do. It does not make any sense, to deduct the whole program by asking in an online forum, because this is extremely inefficient and extremely error prone.

If the developer didn’t write sufficient documentation, you should contact him and ask him about these issues. He will help you much more efficiently and I’m sure the problem will be much quicker solved that way.

Understanding a program’s internals should only be necessary, if you are interested in developing this program, as well. Otherwise, one should read the corresponding documentation, as thoroughly as possible. If not available, I’m sure there are other people who already used this program (unlike us, I presume) and can help you at least to some extent.

1 Like

Im not sure I know what you mean. The screenshot is a recipe from the developer…

I’ll try and contact the developer. However, the program has a user interface on a PC which looks like this (http://www.dohm.com.au/coca/):

But in doesnt on Linux, which is why I try to do it in Terminal. The program makes ICC profiles.

This might not be helpfull, but I did this:

peter@peter-desktop:~/CoCa_Linux$ python2 CoCa_Linux.py || python3 CoCa_Linux.py 
Target Image file name (incl. full path): /home/peter/CoCa_Linux/ScanMate11K Provia cq16bit kopi.tif
Profile information: Device:  [Camera]:SM
Profile information: Model:  [DSLR]:11K
Profile information: Profile Unique Description:  [CoCa]:ScanMate11K Provia cq16bitG22
Profile information: Copyright:  [None]:

Choose target type:
	1.	Xrite ColorChecker 24-patch
	2.	Xrite ColorChecker SG
	3.	CMP Checker 24-patch
	4.	CMP Digital TargeT 003
	5.	CMP Digital Target-3
	6.	CMP Digital Target-4
	7.	HutchColor HCT
	8.	LaserSoft DCPro
	9.	QPcard 201
	10.	QPcard 202
	11.	IT8.7
Target Type choice:  [1]:11
To use generic reference file press Enter, otherwise press "N" [Y]:n
Enter Reference File name (incl. full path): /home/peter/CoCa_Linux/F180316 kopi.txt

Adjust target image for perspective distortion (Y/N):  [N]:n

Choose gamma or press ENTER to accept default:  [2.2]:2.2

Choose Profile Algorithm:
	1.	Lab clut
	2.	XYZ clut
	3.	Display XYZ clut + Matrix
	4.	Gamma + Matrix
	5.	Shaper + Matrix
	6.	Matrix only
	7.	Single Gamma + Matrix
	8.	Single Shaper + Matrix
Algorithm choice:  [1]:2

Choose Profile Quality:
	1.	Low
	2.	Medium
	3.	High
Quality choice:  [3]:2

Choose White Point (range 0.4 to 1.5) or press ENTER to accept default:  [1.0]:

Select Default intent
	1.	Perceptual
	2.	Rel. Colorimetric
	3.	6Saturation
	4.	Abs. Colorimetric
Default Intent choice:  [1]:1
/bin/sh: 1: /home/peter/CoCa_Linux/scanin.sh: not found
ERROR! "Scanin" process did not succeed. No *.ti3 file found. Aborting
Press any key.

But as far as I can understand from this text from the developer I have to do something more at the end:

import os
import sys
import subprocess


CONST_GAMMA = '2.2'
CONST_WB = '1.0'
CONST_ARG_BIN_PTH = os.path.dirname(os.path.realpath(__file__)) + '/argyll/bin/'
CONST_ARG_REF_PTH = os.path.dirname(os.path.realpath(__file__)) + '/argyll/ref/'

os.system('clear')
script_pth = os.path.dirname(os.path.realpath(__file__)) + '/'

def default_input( message, defaultVal ):
    if defaultVal:
        return raw_input( "%s [%s]:" % (message,defaultVal) ) or defaultVal
    else:
        return raw_input( "%s " % (message) )

icc_file = raw_input('Target Image file name (incl. full path): ')

if os.path.isfile(icc_file):
    temp_file = os.path.splitext(icc_file)[0]

    device_info = default_input('Profile information: Device: ', 'Camera')
    model_info = default_input('Profile information: Model: ', 'DSLR')
    prof_info = default_input('Profile information: Profile Unique Description: ', 'CoCa')
    copyright_info = default_input('Profile information: Copyright: ', 'None')

    print
    print 'Choose target type:'
    print '\t1.\tXrite ColorChecker 24-patch'
    print '\t2.\tXrite ColorChecker SG'
    print '\t3.\tCMP Checker 24-patch'
    print '\t4.\tCMP Digital TargeT 003'
    print '\t5.\tCMP Digital Target-3'
    print '\t6.\tCMP Digital Target-4'
    print '\t7.\tHutchColor HCT'
    print '\t8.\tLaserSoft DCPro'
    print '\t9.\tQPcard 201'
    print '\t10.\tQPcard 202'
    print '\t11.\tIT8.7'
    target_type = default_input('Target Type choice: ', '1')

    tmp = default_input('To use generic reference file press Enter, otherwise press "N"', 'Y')
    if tmp.upper() == 'Y':
        if target_type == '1':
            checker_cie = '"' + CONST_ARG_REF_PTH + 'ColorChecker.cie"'
        elif target_type == '3':
            checker_cie = '"' + CONST_ARG_REF_PTH + 'ColorChecker.cie"'
        elif target_type == '9':
            checker_cie = '"' + CONST_ARG_REF_PTH + 'QPcard_201.cie"'
        elif target_type == '10':
            checker_cie = '"' + CONST_ARG_REF_PTH + 'QPcard_202.cie"'
        else:
            print
            print 'ERROR! Generic Reference File does not exist for selected target.'
            checker_cie = '"' + raw_input('Enter Reference File name (incl. full path): ') + '"'
    else:
            checker_cie = '"' + raw_input('Enter Reference File name (incl. full path): ') + '"'

    print
    perspective = str.upper(default_input('Adjust target image for perspective distortion (Y/N): ', 'N'))
    print
    gamma = default_input('Choose gamma or press ENTER to accept default: ', '2.2')

    print
    algorithm = ['1', '2', '3', '4']
    print 'Choose Profile Algorithm:'
    print '\t1.\tLab clut'
    print '\t2.\tXYZ clut'
    print '\t3.\tDisplay XYZ clut + Matrix'
    print '\t4.\tGamma + Matrix'
    print '\t5.\tShaper + Matrix'
    print '\t6.\tMatrix only'
    print '\t7.\tSingle Gamma + Matrix'
    print '\t8.\tSingle Shaper + Matrix'
    algorithm = default_input('Algorithm choice: ', '1')

    print
    print 'Choose Profile Quality:'
    print '\t1.\tLow'
    print '\t2.\tMedium'
    print '\t3.\tHigh'
    quality = default_input('Quality choice: ', '3')

    print
    wp = default_input('Choose White Point (range 0.4 to 1.5) or press ENTER to accept default: ', '1.0')

    print
    print 'Select Default intent'
    print '\t1.\tPerceptual'
    print '\t2.\tRel. Colorimetric'
    print '\t3.\t6Saturation'
    print '\t4.\tAbs. Colorimetric'
    def_intent = default_input('Default Intent choice: ', '1')

    if def_intent == '1':
        def_intent = ' -Z p'
    elif def_intent == '2':
        def_intent = ' -Z r'
    elif def_intent == '3':
        def_intent = ' -Z s'
    elif def_intent == '4':
        def_intent = ' -Z a'
    else:
        def_intent = ''

    checker = ''
    if target_type == '1':
        checker = '"' + CONST_ARG_REF_PTH + 'ColorChecker.cht"'
    elif target_type == '2':
        checker = '"' + CONST_ARG_REF_PTH + 'ColorCheckerSG.cht"'
    elif target_type == '3':
        checker = '"' + CONST_ARG_REF_PTH + 'ColorChecker.cht"'
    elif target_type == '4':
        checker = '"' + CONST_ARG_REF_PTH + 'CMP_DT_003.cht"'
    elif target_type == '5':
        checker = '"' + CONST_ARG_REF_PTH + 'CMP_Digital_Target-3.cht"'
    elif target_type == '6':
        checker = '"' + CONST_ARG_REF_PTH + 'CMP_Digital_Target-3.cht"'
    elif target_type == '7':
        checker = '"' + CONST_ARG_REF_PTH + 'Hutchcolor.cht"'
    elif target_type == '8':
        checker = '"' + CONST_ARG_REF_PTH + 'LaserSoftDCPro.cht"'
    elif target_type == '9':
        checker = '"' + CONST_ARG_REF_PTH + 'QPcard_201.cht"'
    elif target_type == '10':
        checker = '"' + CONST_ARG_REF_PTH + 'QPcard_202.cht"'
    elif target_type == '11':
        checker = '"' + CONST_ARG_REF_PTH + 'it8.cht"'
    else:
        checker = '"' + CONST_ARG_REF_PTH + 'ColorChecker.cht"'

    if quality == '1':
        quality = 'l'
    elif quality == '2':
        quality = 'm'
    elif quality == '3':
        quality = 'h'
    else:
        quality = 'h'

    if perspective == 'Y':
        perspective = ''
    else:
        perspective = ''

    if algorithm == '1':
        algorithm = 'l'
    elif algorithm == '2':
        algorithm = 'x'
    elif algorithm == '3':
        algorithm = 'X'
    elif algorithm == '4':
        algorithm = 'g'
    elif algorithm == '5':
        algorithm = 's'
    elif algorithm == '6':
        algorithm = 'm'
    elif algorithm == '7':
        algorithm = 'G'
    elif algorithm == '8':
        algorithm = 'S'
    else:
        algorithm = 'l'

    if gamma != '2.2':
        gamma = '-G '+ gamma + ' '
    else:
        gamma = ''

    if wp != '1.0':
        wp = '-U '+ wp + ' '
    else:
        wp = ''

    out_text = '"' + CONST_ARG_BIN_PTH + 'scanin" -v ' + gamma + perspective + '"' + script_pth + icc_file + '" ' + checker + ' ' + checker_cie

    outfile = script_pth + 'scanin.sh'
    out_file = open(outfile, 'w')
    out_file.write('#!/bin/bash')
    out_file.write(out_text)
    out_file.close()
    os.system('chmod +x ' + outfile)
    p = subprocess.Popen(outfile, shell=True)
    p.wait()

    if os.path.isfile(script_pth + temp_file + '.ti3'):
        outfile = script_pth + 'colprof.sh'
        out_text = CONST_ARG_BIN_PTH + 'colprof -v4 -A' + device_info + ' -M ' + model_info + ' -D' + prof_info + ' -C' + copyright_info +\
                   def_intent + ' -q' + quality + ' -a' + algorithm + ' ' + '"' + temp_file + '"'
        out_file = open(outfile, 'w')
        out_file.write(out_text)
        out_file.close()
        p = subprocess.Popen(outfile, shell=True)
        p.wait()
    else:
        print 'ERROR! "Scanin" process did not succeed. No *.ti3 file found. Aborting'
        raw_input('Press any key.')

else:
    print 'File NOT found. Aborting.'
    raw_input('Press any key.')

if os.path.isfile(script_pth + 'colprof.sh'):
    os.remove(script_pth + 'colprof.sh')

if os.path.isfile(script_pth + 'scanin.sh'):
    os.remove(script_pth + 'scanin.sh')


tmp = open(script_pth + temp_file + '.ti3', 'w')
tmp.close()

#if os.path.isfile(script_pth + temp_file + '.t3'):
os.remove(script_pth + temp_file + '.ti3')

print ''
print 'Color Profile file has been saved to: "' + script_pth + '"'

raw_input('Press ENTER to exit.')

This might not get me anywhere and thats ok, but Im trying anyway… :slight_smile:

PS The .ti3 is supposed to be created while doing this (its not a pre-existing file).

To avoid fundamental errors, you should provide a path that has no spaces in it. Sometimes this may cause issues.

Makes no difference.

The crucial issue seems to be the part

outfile = script_pth + 'scanin.sh'
    out_file = open(outfile, 'w')
    out_file.write('#!/bin/bash')
    out_file.write(out_text)
    out_file.close()
    os.system('chmod +x ' + outfile)
    p = subprocess.Popen(outfile, shell=True)
    p.wait()

Here, a bash script is created which then creates the ti3 file.
However, this failed, as we see in the error message:

/bin/sh: 1: /home/peter/CoCa_Linux/scanin.sh: not found

Why the file /home/peter/CoCa_Linux/scanin.sh couldn’t be created and/or not be written to, I really can’t say.

Unfortunately, the programmer did not include a handler for this case. You might try to add

except IOError as e:
    print "I/O error({0}): {1}".format(e.errno, e.strerror)

after

out_file = open(outfile, 'w')

and see what it says.

Maybe, it’s a rights issue. You might try chmod -R a+w /home/peter/CoCa_Linux before executing the script but this is just a wild guess.

Thanks - I’ll see if I’m able to do what you suggest :wink:
I dont know if this is relevant or, not but there is a scanin.sh file created when I get the error message. When I open it in the text editor it just repeat the same error message though:
#!/bin/bash"/home/peter/CoCa_Linux/argyll/bin/scanin" -v “/home/peter/CoCa_Linux//home/peter/CoCa_Linux/ScanMate11KProviacq16bitkopi.tif” “/home/peter/CoCa_Linux/argyll/ref/it8.cht” “/home/peter/CoCa_Linux/F180316kopi.txt”

Ive been searching a bit more. If I write ‘scanin’ in terminal it seems like this is a program I have… and I think I have to do something like this: https://www.argyllcms.com/doc/scanin.html

Is this exactly the way it is written or are there line breaks missing? Without line breaks at the correct space, it won’t work.

Thats just an errormmessage.

And Im sorry about this… I was certain the script was supposed to have created the ti3 file, but that file has to be created using scanin first… Im trying to figure it out :stuck_out_tongue: