Settings menu using list style (curses)
()
| 7748 | return session |
| 7749 | raise ValueError('This session is not accepting input right now.') |
| 7750 | |
| 7751 | |
| 7752 | def create_job(label, command, cwd, kind='process', real_termux=False): |
| 7753 | session_id = next_session_id('job') |
| 7754 | log_file = os.path.join(LOGS_DIR, session_id + '.log') |
| 7755 | pid_file = os.path.join(PIDS_DIR, session_id + '.pid') |
| 7756 | exit_file = os.path.join(EXITS_DIR, session_id + '.exit') |
| 7757 | job = { |
| 7758 | 'id': session_id, |
| 7759 | 'label': label, |
| 7760 | 'command': command, |
| 7761 | 'started_at': now_iso(), |
| 7762 | 'log_file': log_file, |
| 7763 | 'pid_file': pid_file, |
| 7764 | 'exit_file': exit_file, |
| 7765 | 'running': True, |
| 7766 | 'exit_code': None, |
| 7767 | 'real_termux': real_termux, |
| 7768 | 'cwd': cwd, |
| 7769 | 'cwd_file': '', |
| 7770 | 'interactive': False, |
| 7771 | 'kind': kind, |
| 7772 | 'closed': False |
| 7773 | } |
| 7774 | with STATE_LOCK: |
| 7775 | jobs = _prune_job_history(load_jobs()) |
| 7776 | jobs[session_id] = job |
| 7777 | save_jobs(jobs) |
| 7778 | with open(log_file, 'w', encoding='utf-8') as handle: |
| 7779 | handle.write('[' + now_iso() + '] Starting: ' + command + '\n') |
| 7780 | return job |
| 7781 | |
| 7782 | |
| 7783 | def build_wrapper_script(job, shell_command, cwd): |
| 7784 | wrapper_path = os.path.join(WRAPPERS_DIR, job['id'] + '.sh') |
| 7785 | content = """#!/data/data/com.termux/files/usr/bin/bash |
| 7786 | set +e |