Writing an Augeas lens - mongodb

I need to edit one line in /etc/mongodb.conf
auth = true
Augeas has a mongo lens, however it only works on augeas > 1.0
I am completely stuck on augeas 0.9 because it is the latest version in the epel repo, and I can not compile augeas from github.
As a work around, I'm trying to write my own augeas lens that will work on augeas 0.9
What I have so far is this
module Spencer =
autoload xfm
let entry = key /[a-z]+/ . del /[ \t]*=[ \t]*/ "=" . store /[a-z]+/
let lns = [ entry . del "\n" "\n" ] *
test lns get "auth = false\nfoo = bar\n" = ?
let filter = incl "/etc/mongodb.conf"
let xfm = transform lns filter
When I try and use the puppet type to apply the lens to /etc/mongodb.conf, I get an error "Iterated lens matched less than it should".
puppet apply augmongo.pp --debug --verbose --summarize
Info: Applying configuration version '1385024927'
Debug: Augeas[auth-mongo](provider=augeas): Opening augeas with root /, lens path , flags 64
Debug: Augeas[auth-mongo](provider=augeas): Augeas version 0.9.0 is installed
Test result: /usr/share/augeas/lenses/dist/spencer.aug:8.0-.44:
{ "auth" = "false" }
{ "foo" = "bar" }
Debug: Augeas[auth-mongo](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[auth-mongo](provider=augeas): sending command 'set' with params ["/files/etc/mongodb.conf/auth", "true"]
Debug: Augeas[auth-mongo](provider=augeas): Put failed on one or more files, output from /augeas//error:
Debug: Augeas[auth-mongo](provider=augeas): /augeas/files/etc/mongodb.conf/error = put_failed
Debug: Augeas[auth-mongo](provider=augeas): /augeas/files/etc/mongodb.conf/error/pos = 1
Debug: Augeas[auth-mongo](provider=augeas): /augeas/files/etc/mongodb.conf/error/lens = /usr/share/augeas/lenses/dist/spencer.aug:6.10-.37:
Debug: Augeas[auth-mongo](provider=augeas): /augeas/files/etc/mongodb.conf/error/message = Iterated lens matched less than it should
Debug: Augeas[auth-mongo](provider=augeas): Closed the augeas connection
Error: /Stage[main]/Augmongo/Augeas[auth-mongo]: Could not evaluate: Save failed with return code false, see debug
Debug: Finishing transaction 69857417180740
Debug: Storing state
Debug: Stored state in 0.13 seconds
What is wrong with the lens?
How can I test a lens from the command line and take puppet out of the equation?

RHEL 6.4 just upgraded to Augeas 1.0. See https://rhn.redhat.com/errata/RHSA-2013-1537.html.
You should be able to rebuild the packages, or wait for CentOS to do that for you.

I have had similar issues with augeas & puppet. Applying changes seemed to end with the error Could not evaluate: Save failed with return code false every time. This turned out to be an syntax issue. I had:
set spec[user = '%somegroup']/host_group/command/tag NOPASSWD
(notice two empty space between tag and NOPASSWD).
When I tried the same command with one empty space, the issue was solved.
Looking into the template/lens (spencer.aug, line 6.10-.37) might offer some clue at what went wrong.

Related

Odoo-sh Upgrade : How to disable a view / uninstall a module during upgrade process (v13 to v15)?

During the upgrade process on odoo.sh on branch BrStaging, there are errors in the log panel. Some obsolete custom Modules or Views are the cause of these errors. To disable or uninstall them, we have to use SQL queries because we cannot enter odoo which cannot start:
My Try: using in Odoo-sh> SHELL-Tab, the shell command : psql:
To disable a view
UPDATE public.ir_ui_view SET active = false WHERE id = 10381;
To disable/uninstall a module
UPDATE ir_module_module set state='to remove'
WHERE name in ('my_custom_module') and state='installed';
...have tried that request too:
UPDATE ir_module_module set state='uninstallable'
WHERE name in ('my_custom_module') and state='installed';
...But it does t work: after a commit or restart (command: odoosh-restart) the related error still remains!
How to disable a view and uninstall a module during the upgrade process from v13 to v15 ??
The solution, I have found is using a pre-migrate.py file into one of my custom module : my_custom_module/migrations/15.0.0.0.0/pre-migrate.py
which contain the Sql query that i need to execute, to correct the upgrade-log-Error:
def migrate(cr, version):
# TO CORRECT UPGRADE ERROR 1 : Element '<xpath expr="//xxxx">' cannot be located in parent view
cr.execute("""
update ir_ui_view v
set inherit_id = NULL, mode='primary', active = false
where
v.id in (10563,10539)
""")

CentOS EPEL fail2ban not processing systemd journal for tomcat

I've installed fail2ban 0.10.5-2.el7 from EPEL on CentOS 7.8. I'm trying to get it to work with systemd for processing a Tomcat log (also systemd).
In jail.local I added:
[guacamole]
enabled = true
port = http,https
backend = systemd
In filter.d/guacamole.conf:
[Definition]
failregex = Authentication attempt from <HOST> for user "[^"]*" failed\.$
ignoreregex =
journalmatch = _SYSTEMD_UNIT=tomcat.service + _COMM=java
If I run journalctl -u tomcat.service I see all the log lines. The ones I am interested in look like this:
May 18 13:58:26 myhost catalina.sh[42065]: 13:58:26.485 [http-nio-8080-exec-6] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from 1.2.3.4 for user "test" failed.
If I redirect journalctl -u tomcat.service to a log file, and process it with fail2ban-regex then it works exactly the way I want it to work, finding all the lines it needs.
% fail2ban-regex /tmp/j9 /etc/fail2ban/filter.d/guacamole.conf
Running tests
=============
Use failregex filter file : guacamole, basedir: /etc/fail2ban
Use log file : /tmp/j9
Use encoding : UTF-8
Results
=======
Failregex: 47 total
|- #) [# of hits] regular expression
| 1) [47] Authentication attempt from <HOST> for user "[^"]*" failed\.$
`-
Ignoreregex: 0 total
Date template hits:
|- [# of hits] date format
| [1] ExYear(?P<_sep>[-/.])Month(?P=_sep)Day(?:T| ?)24hour:Minute:Second(?:[.,]Microseconds)?(?:\s*Zone offset)?
| [570] {^LN-BEG}(?:DAY )?MON Day %k:Minute:Second(?:\.Microseconds)?(?: ExYear)?
`-
Lines: 571 lines, 0 ignored, 47 matched, 524 missed
[processed in 0.12 sec]
However, if fail2ban reads the journal directly then it does not work:
fail2ban-regex systemd-journal /etc/fail2ban/filter.d/guacamole.conf
It comes back right away, and processes 0 lines!
Running tests
=============
Use failregex filter file : guacamole, basedir: /etc/fail2ban
Use systemd journal
Use encoding : UTF-8
Use journal match : _SYSTEMD_UNIT=tomcat.service + _COMM=java
Results
=======
Failregex: 0 total
Ignoreregex: 0 total
Lines: 0 lines, 0 ignored, 0 matched, 0 missed
[processed in 0.00 sec]
I've tried to remove _COMM=java. It doesn't make a difference.
If I leave out the journal match line altogether, it at least processes all the lines from the journal, but does not find any matches (even though, as I mentioned, it processes a dump of the log file fine):
Running tests
=============
Use failregex filter file : guacamole, basedir: /etc/fail2ban
Use systemd journal
Use encoding : UTF-8
Results
=======
Failregex: 0 total
Ignoreregex: 0 total
Lines: 202271 lines, 0 ignored, 0 matched, 202271 missed
[processed in 34.54 sec]
Missed line(s): too many to print. Use --print-all-missed to print all 202271 lines
Either this is a bug, or I'm missing a small detail.
Thanks for any help you can provide.
To make sure the filter definition is properly initialised, it would be good to include the common definition. Your filter definition (/etc/fail2ban/filter.d/guacamole.conf) would therefore look like:
[INCLUDES]
before = common.conf
[Definition]
journalmatch = _SYSTEMD_UNIT='tomcat.service'
failregex = Authentication attempt from <HOST> for user "[^"]*" failed\.$
ignoreregex =
A small note given that your issue only occurs with systemd but not flat files, could you try the same pattern without $ at the end? Maybe there is an issue with the end of line when printed to the journal?
In your jail definition (/etc/fail2ban/jail.d/guacamole.conf), remember to define the ban time/find time/retries if they haven't already been defined in the default configuration:
[guacamole]
enabled = true
port = http,https
maxretry = 3
findtime = 1h
bantime = 1d
# "backend" specifies the backend used to get files modification.
# systemd: uses systemd python library to access the systemd journal.
# Specifying "logpath" is not valid for this backend.
# See "journalmatch" in the jails associated filter config
backend = systemd
Remember to restart the fail2ban service after doing such changes.

python tox - losing stuff on the way to the testing spot

this is my first time using tox to create a python package. I didn't underestimate this task and read myself a little bit into how setuptools and pyscaffold works, what does what and why and so on, got some yt-videos to grasp how to get it on.
But, guess what, it doesn't work, and i have absolutely no clue why.
This is what i did:
putup --tox river
then i placed my sources under src/
and some tests under tests/
so this is my folder structure so far:
river/
src/
dispatcher/
__init__.py
updater.py
river/
__init__.py
dispatcher_config.py
dispatcher.py
flow.py
logger.py
log_config.yml
tests/
__init__.py
test_cases.py
AUTHORS.rst
CHANGELOG.rst
LICENSE.txt
README.rst
setup.cfg
setup.py
tox.ini
log_config.yml
all i want to achieve for now is getting my tests running properly.
tox.ini :
[tox]
minversion = 2.4
envlist = default
[testenv]
setenv = TOXINIDIR = {toxinidir}
sitepackages = True
commands =
python --version
pytest
deps = pytest
setup.cfg - almost unchanged :
# This file is used to configure your project.
# Read more about the various options under:
# http://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files
[metadata]
name = river
description = Add a short description here!
author = Kristian Jülfs
author-email = kristian.juelfs#...
license = mit
long-description = file: README.rst
long-description-content-type = text/x-rst; charset=UTF-8
url = https://github.com/pyscaffold/pyscaffold/
project-urls =
Documentation = https://pyscaffold.org/
# Change if running only on Windows, Mac or Linux (comma-separated)
platforms = any
# Add here all kinds of additional classifiers as defined under
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers =
Development Status :: 4 - Beta
Programming Language :: Python
[options]
zip_safe = False
packages = find:
include_package_data = True
package_dir =
=src
# DON'T CHANGE THE FOLLOWING LINE! IT WILL BE UPDATED BY PYSCAFFOLD!
setup_requires = pyscaffold>=3.2a0,<3.3a0
# Add here dependencies of your project (semicolon/line-separated), e.g.
# install_requires = numpy; scipy
# The usage of test_requires is discouraged, see `Dependency Management` docs
# tests_require = pytest; pytest-cov
# Require a specific Python version, e.g. Python 2.7 or >= 3.4
# python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
[options.packages.find]
where = src
exclude =
tests
[options.extras_require]
# Add here additional requirements for extra features, to install with:
# `pip install river[PDF]` like:
# PDF = ReportLab; RXP
# Add here test requirements (semicolon/line-separated)
testing =
pytest
pytest-cov
# flake8
[options.entry_points]
# Add here console scripts like:
# console_scripts =
# script_name = river.module:function
# For example:
# console_scripts =
# fibonacci = river.skeleton:run
# And any other entry points, for example:
# pyscaffold.cli =
# awesome = pyscaffoldext.awesome.extension:AwesomeExtension
[test]
# py.test options when running `python setup.py test`
#addopts = --verbose
extras = True
[aliases]
dists = bdist_wheel
[bdist_wheel]
# Use this option if your package is pure-python
universal = 1
[build_sphinx]
source_dir = docs
build_dir = build/sphinx
[devpi:upload]
# Options for the devpi: PyPI server and packaging tool
# VCS export must be deactivated since we are using setuptools-scm
no-vcs = 1
formats = bdist_wheel
[tool:pytest]
addopts = --verbose
norecursedirs =
dist
build
.tox
[flake8]
# Some sane defaults for the code style checker flake8
exclude =
.tox
build
dist
.eggs
docs/conf.py
[pyscaffold]
# PyScaffold's parameters when the project was created.
# This will be used when updating. Do not change!
version = 3.2.1
package = river
extensions =
tox
alrighti so far. Whatever i'm missing, i don't get it.
when i start tox on verbose,
tox -r -vvv
i get this (cut)
...
creating '/tmp/pip-wheel-rb7acy7z/river-0.0.post0.dev1+gc371b6b.dirty-py2.py3-none-any.whl' and adding '.' to it
adding 'dispatcher/__init__.py'
adding 'dispatcher/updater.py'
adding 'river/__init__.py'
adding 'river/dispatcher.py'
adding 'river/dispatcher_config.py'
adding 'river/flow.py'
adding 'river/logger.py'
adding 'river-0.0.post0.dev1+gc371b6b.dirty.dist-info/top_level.txt'
adding 'river-0.0.post0.dev1+gc371b6b.dirty.dist-info/WHEEL'
adding 'river-0.0.post0.dev1+gc371b6b.dirty.dist-info/METADATA'
adding 'river-0.0.post0.dev1+gc371b6b.dirty.dist-info/RECORD'
removing build/bdist.freebsd-12.0-RELEASE-p7-amd64/wheel
done
Stored in directory: /home/kjuelf/.cache/pip/wheels/f7/c7/76/923a5b579b9178351cdbe053f020f660101c03b78a4085d281
Removing source in /tmp/pip-req-build-jhc29i8z
Successfully built river
Installing collected packages: river
Successfully installed river-0.0.post0.dev1+gc371b6b.dirty
Cleaning up...
...
default start: run-test-pre
default run-test-pre: PYTHONHASHSEED='4259061550'
default finish: run-test-pre after 0.00 seconds
default start: run-test
default run-test: commands[0] | python --version
setting PATH=/usr/home/kjuelf/infra/river/.tox/default/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/kjuelf/bin
[11307] /usr/home/kjuelf/infra/river$ /usr/home/kjuelf/infra/river/.tox/default/bin/python --version
Python 3.6.9
default run-test: commands[1] | pytest
setting PATH=/usr/home/kjuelf/infra/river/.tox/default/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/kjuelf/bin
WARNING: test command found but not installed in testenv
cmd: /usr/local/bin/pytest
env: /usr/home/kjuelf/infra/river/.tox/default
Maybe you forgot to specify a dependency? See also the whitelist_externals envconfig setting.
DEPRECATION WARNING: this will be an error in tox 4 and above!
[11308] /usr/home/kjuelf/infra/river$ /usr/local/bin/pytest
============================================================ test session starts ============================================================
platform freebsd12 -- Python 3.6.9, pytest-4.5.0, py-1.8.0, pluggy-0.12.0 -- /usr/local/bin/python3.6
cachedir: .tox/default/.pytest_cache
rootdir: /usr/home/kjuelf/infra/river, inifile: setup.cfg
plugins: cov-2.7.1, flake8-1.0.4
collected 0 items / 1 errors
================================================================== ERRORS ===================================================================
___________________________________________________ ERROR collecting tests/test_cases.py ____________________________________________________
/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py:359: in get_provider
module = sys.modules[moduleOrReq]
E KeyError: 'river'
During handling of the above exception, another exception occurred:
src/river/logger.py:18: in <module>
config = resource_string("river", "log_config.yml")
/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py:1156: in resource_string
return get_provider(package_or_requirement).get_resource_string(
/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py:361: in get_provider
__import__(moduleOrReq)
E ModuleNotFoundError: No module named 'river'
...
i mean, first
Successfully built river
then
E ModuleNotFoundError: No module named 'river'
in pkg_resources/__ init __.py - KeyError: 'river'
i can't get a clue whats wrong with pkg_resources here - where is my stuff gone suddenly o_0 ??!
I also don't get what that warning means:
WARNING: test command found but not installed in testenv
it's there, pytest works, and the dependency is set in tox.ini
lost in weirdness

pacman -Syuu : error: failed retrieving file ("Operation too slow" and "SSL certificate problem")

I am having troubles when trying to upgrade my Portable Msys2 under Win 10 with pacman -Syuu, as detailed below.
I did this before with no problem.
What could the problem and solution be?
$ pacman -Syuu
:: Synchronizing package databases...
mingw32 is up to date
mingw64 is up to date
msys is up to date
:: Starting core system upgrade...
there is nothing to do
:: Starting full system upgrade...
warning: grep: downgrading from version 3.1-1 to version 3.0-2
warning: libgc: downgrading from version 8.0.0-1 to version 7.6.8-1
warning: mingw-w64-x86_64-binutils: downgrading from version 2.31.1-2 to version 2.30-5
:: Replace mingw-w64-x86_64-minizip with mingw64/mingw-w64-x86_64-zlib? [Y/n] y
:: Replace mingw-w64-x86_64-vulkan with mingw64/mingw-w64-x86_64-vulkan-loader? [Y/n] y
resolving dependencies...
looking for conflicting packages...
Packages (217) autogen-5.18.16-1 bison-3.3.2-1 brotli-1.0.7-1 ca-certificates-20180409-1 cmake-3.13.2-1 curl-7.64.0-2 diffutils-3.7-1 doxygen-1.8.15-1
...
Total Download Size: 1400.65 MiB
Total Installed Size: 9648.15 MiB
Net Upgrade Size: 261.06 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages...
error: failed retrieving file 'mingw-w64-x86_64-qt5-5.12.1-5-any.pkg.tar.xz' from repo.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'mingw-w64-x86_64-qt5-5.12.1-5-any.pkg.tar.xz' from sourceforge.net : SSL certificate problem: unable to get local issuer certificate
error: failed retrieving file 'mingw-w64-x86_64-qt5-5.12.1-5-any.pkg.tar.xz' from www2.futureware.at : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'mingw-w64-x86_64-qt5-5.12.1-5-any.pkg.tar.xz' from mirror.yandex.ru : SSL certificate problem: unable to get local issuer certificate
warning: failed to retrieve some files
error: failed to commit transaction (download library error)
Errors occurred, no packages were upgraded.
As per this, my repo configuration seems to be ok:
$ pacman-conf.exe
[options]
RootDir = /
DBPath = /var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
HookDir = /etc/pacman.d/hooks/
GPGDir = /etc/pacman.d/gnupg/
LogFile = /var/log/pacman.log
HoldPkg = pacman
Architecture = i686
CheckSpace
UseDelta = 0.000000
CleanMethod = KeepInstalled
SigLevel = PackageRequired
SigLevel = PackageTrustedOnly
SigLevel = DatabaseOptional
SigLevel = DatabaseTrustedOnly
LocalFileSigLevel = PackageOptional
LocalFileSigLevel = PackageTrustedOnly
[mingw32]
Usage = All
Server = http://repo.msys2.org/mingw/i686/
Server = https://sourceforge.net/projects/msys2/files/REPOS/MINGW/i686/
Server = http://www2.futureware.at/~nickoe/msys2-mirror/mingw/i686/
Server = https://mirror.yandex.ru/mirrors/msys2/mingw/i686/
[mingw64]
Usage = All
Server = http://repo.msys2.org/mingw/x86_64/
Server = https://sourceforge.net/projects/msys2/files/REPOS/MINGW/x86_64/
Server = http://www2.futureware.at/~nickoe/msys2-mirror/mingw/x86_64/
Server = https://mirror.yandex.ru/mirrors/msys2/mingw/x86_64/
[msys]
Usage = All
Server = http://repo.msys2.org/msys/i686/
Server = https://sourceforge.net/projects/msys2/files/REPOS/MSYS2/i686/
Server = http://www2.futureware.at/~nickoe/msys2-mirror/msys/i686/
Server = https://mirror.yandex.ru/mirrors/msys2/msys/i686/
Related:
https://github.com/msys2/MINGW-packages/issues/1887
https://bbs.archlinux.org/viewtopic.php?id=199693
https://sourceforge.net/p/msys2/discussion/general/thread/8427aab0/
EDIT
It was suggested in a comment that I execute pacman-mirrors ...
There seems to be no such executable in my system (either script, alias, etc.)
On the other hand, it seems I already have pacman-mirrors, and that it does not provide any executable (at least in msys2). Is this correct?
$ updatedb
$ locate pacman-mirrors
/var/cache/pacman/pkg/pacman-mirrors-20180604-2-any.pkg.tar.xz
/var/lib/pacman/local/pacman-mirrors-20180604-2
/var/lib/pacman/local/pacman-mirrors-20180604-2/desc
/var/lib/pacman/local/pacman-mirrors-20180604-2/files
/var/lib/pacman/local/pacman-mirrors-20180604-2/mtree
$ pacman -Ql pacman-mirrors
pacman-mirrors /etc/
pacman-mirrors /etc/pacman.d/
pacman-mirrors /etc/pacman.d/mirrorlist.mingw32
pacman-mirrors /etc/pacman.d/mirrorlist.mingw64
pacman-mirrors /etc/pacman.d/mirrorlist.msys
$ pacman --needed -S bash pacman pacman-mirrors msys2-runtime
warning: bash-4.4.023-1 is up to date -- skipping
warning: pacman-5.1.2-2 is up to date -- skipping
warning: pacman-mirrors-20180604-2 is up to date -- skipping
warning: msys2-runtime-2.11.2-1 is up to date -- skipping
You can disable the timeout of pacman with the parameter --disable-download-timeout. Then you should be able to download
http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-qt5-5.12.1-5-any.pkg.tar.xz
It's described on the man-page for pacman.
Also --gpgdir to Specify a directory of files used by GnuPG to verify package signatures might be useful.
Additional you can consider using the parameter --noconfirm
to bypass any and all “Are you sure?” messages.
About the certificates I'm not sure, perhaps the local paths are not configured correctly. Nevertheless you've two domains, that still serve by http.
In browser the download works btw. it just has finished, the screenshot is still showing the download in progress:
I've also faced this problem but I got the solution: Open Add or Remove Softwares and go to Preferences and then change your official repositories to Canada then Refresh mirror lists
It may work now
The following were the steps I used to solve the problem;
sudo nano /etc/pacman.d/mirrorlist (to open the mirror list on manjaro or any arch based distro)
In the mirror list, all the source servers will be active. Put a hash at the beginning of each line of a selected active server to prevent the server from being contacted during the download process. You don't need all of the servers to be active, so only allow countries close to you and place a hash in front of all other servers that aren't.
## Generated on 2022-08-16 12:13
##
## Please use 'pacman-mirrors -f [NUMBER] [NUMBER]' to modify mirrorlist
## (Use 0 for all mirrors)
##
## Country : Poland
# Server = https://mirror.tuchola-dc.pl/manjaro/stable/$repo/$arch
## Country : Hungary
# Serve<p>r = http://mirror.infotronik.hu/mirrors/pub/manjaro/stable/$repo/$arch
## Country : Germany
Server = http://ftp.tu-chemnitz.de/pub/linux/manjaro/stable/$repo/$arch
## Country : Brazil
# Server = http://linorg.usp.br/manjaro/stable/$repo/$arch
## Country : Costa_Rica
# Server = https://mirrors.ucr.ac.cr/manjaro/stable/$repo/$arch
## Country : Australia
Server = http://mirror.ventraip.net.au/Manjaro/stable/$repo/$arch
## Country : Australia
Server = http://mirror.ventraip.net.au/Manjaro/stable/$repo/$arch
## Country : Germany
Server = http://ftp.rz.tu-bs.de/pub/mirror/manjaro.org/repos/stable/$repo/$arch
## Country : Germany
Server = https://repo.rhindon.net/manjaro/stable/$repo/$arch
## Country : Brazil
#Server = https://manjaro.c3sl.ufpr.br/stable/$repo/$arch
## Country : United_States
Server = https://mirror.math.princeton.edu/pub/manjaro/stable/$repo/$arch
## Country : Poland
#Server = http://mirror.chmuri.net/manjaro/stable/$repo/$arch
## Country : China
#Server = https://mirrors.sjtug.sjtu.edu.cn/manjarostable/$repo/$arch
## Country : China</p>
#Server = https://mirrors.ustc.edu.cn/manjaro/stable/$repo/$arch
## Country : Germany
Server =https://mirror.netzspielplatz.de/manjaro/packages/stable/$repo/$arch```

Log IPython output?

Is there any way to make IPython's logging capability include output as well as input?
This is what a log file looks like currently:
#!/usr/bin/env python
# 2012-08-06.py
# IPython automatic logging file
# 12:02
# =================================
print "test"
I'd like to have one more line show up:
#!/usr/bin/env python
# 2012-08-06.py
# IPython automatic logging file
# 12:02
# =================================
print "test"
# test
(the # is because I assume that is needed to prevent breaking IPython's logplay feature)
I suppose this is possible using IPython notebooks, but on at least one machine I need this for, I'm limited to ipython 0.10.2.
EDIT: I'd like to know how to set this up automatically, i.e. within the configuration file. Right now my config looks like
from time import strftime
import os
logfilename = strftime('ipython_log_%Y-%m-%d')+".py"
logfilepath = "%s/%s" % (os.getcwd(),logfilename)
file_handle = open(logfilepath,'a')
file_handle.write('########################################################\n')
out_str = '# Started Logging At: '+ strftime('%Y-%m-%d %H:%M:%S\n')
file_handle.write(out_str)
file_handle.write('########################################################\n')
file_handle.close()
c.TerminalInteractiveShell.logappend = logfilepath
c.TerminalInteractiveShell.logstart = True
but specifying c.TerminalInteractiveShell.log_output = True seems to have no affect
There's the -o option for %logstart:
-o: log also IPython's output. In this mode, all commands which
generate an Out[NN] prompt are recorded to the logfile, right after
their corresponding input line. The output lines are always
prepended with a '#[Out]# ' marker, so that the log remains valid
Python code.
ADDENDUM: If you are in an interactive ipython session for which logging has already been started, you must first stop logging and then restart:
In [1]: %logstop
In [2]: %logstart -o
Activating auto-logging. Current session state plus future input saved.
Filename : ./ipython.py
Mode : backup
Output logging : True
Raw input log : False
Timestamping : False
State : active
Observe that, after the restart, "Output Logging" is now "True".