ocp-indent and eliom files - ocaml

I installed ocp-indent 1.4.2 via opam. It works fine with most of ocaml files but it fails to indent the eliom files properly. For example the following
{shared{
open Eliom_lib
}}
is indented as
{shared{
open Eliom_lib
}}
The command ocp-indent --print-config gives
base = 2
type = 2
in = 0
with = 0
match_clause = 2
ppx_stritem_ext = 2
max_indent = 2
strict_with = never
strict_else = always
strict_comments = false
align_ops = true
align_params = auto
syntax = mll lwt
Is the configuration wrong?

Related

Browsing through multiple audio files for playback on Asterisk dialplan

I'm trying to make a voicemail system on Asterisk 16, FreePBX 16 and CentOS 7 that lets people browse and choose from a list of prerecorded audio files. When the caller enters the menu to select the audio files, they're told how to browse through the different files. In the /var/lib/asterisk/sounds/ directory, the files are named from 1 to 3 (1.wav, 2.wav etc.) currently and the caller presses 1 to go to the previous file and 2 to go to the next file and 3 to select the current file they're listening to. The extensions part goes as such:
[prerecorded]
exten = s,1,NoOp(Pre-recorded messages)
same = n,Set(LOOP=0)
same = n,Set(FILE=1)
same = n(timeout),Wait(1)
same = n,Playback(browsing_tutorial)
same = n(loop),NoOp(Loop)
same = n,Background(${FILE})
same = n,WaitExten(5)
exten = 1,1,NoOp(Previous file)
same = n,Set(FILE=$[ ${FILE} - 1])
same = n,GoToIf($[ ${FILE} = 0 ]?:s,loop)
same = n,Playback(first_file)
same = n,Set(FILE=1)
same = n,GoTo(s,loop)
exten = 2,1,NoOp(Next file)
same = n,Set(FILE=$[ ${FILE} + 1])
same = n,GoToIf($[ ${FILE} = 4 ]?:s,loop)
same = n,Playback(last_file)
same = n,Set(FILE=3)
same = n,GoTo(s,loop)
exten = #,1,NoOp(Repeat)
same = n,GoTo(s,1)
exten = t,1,NoOp(No input)
same = n,Set(LOOP=$[ ${LOOP} + 1 ])
same = n,GoToIf($[ ${LOOP} > 2 ]?:s,timeout)
same = n,HangUp()
Doing it this way lets me browse through the files, but it warrants editing the extensions every time I add or remove any prerecorded files (which will be done often). If there's any way I can do this without needing to edit the extensions, it would be great.
You can write your own application using native C/C++ interface in asterisk, if you skilled enough. See app_voicemail.c
You also can use AGI or ARI interface and control dialplan with scripted language
Other option is voicemail storage in db and db-driven app using func_odbc

mypy and django: error: Library stubs not installed for "six" (or incompatible with Python 3.9)

I have setup mypy for a django project
[mypy]
# The mypy configurations: https://mypy.readthedocs.io/en/latest/config_file.html
python_version = 3.9
check_untyped_defs = True
# disallow_any_explicit = True
disallow_any_generics = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
ignore_errors = False
ignore_missing_imports = True
implicit_reexport = False
strict_optional = True
strict_equality = True
no_implicit_optional = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unreachable = True
warn_no_return = True
mypy_path = /home/user/app/backend_django/src
plugins =
mypy_django_plugin.main,
mypy_drf_plugin.main
[mypy.plugins.django-stubs]
django_settings_module = project.settings
Now I get
settings.py:21: error: Library stubs not installed for "six" (or incompatible with Python 3.9)
In settings.py I am importing six
So how to get this error resolved.
I have django-stubs installed
try running mypy after adding types-six to your environment:
pip install types-six
see the note in the mypy docs. the behavior of stubs has changed starting from mypy>=0.9.

Python nosetests cover-package and exclude some directories

I'm using nosetests to run unit tests and show the code coverage using (python 2.7):
nosetests -c .noserccover -q
.noserccover file:
[nosetests]
cover-package = src/
with-coverage = 1
xcoverage-file = test_results/coverage.xml
cover-erase = 1
cover-html-dir = build/nosetests
cover-html = 1
with-xunit = 1
xunit-file = test_results/nosetests.xml
verbosity = 2
exclude-dir=src/dir_c
What i want is to include src/dir_a and src/dir_b but exclude src/dir_c.
I guess exclude-dir don't work if you use cover-package. When i run tests, src/dir_c is still included in the coverage.

py2app - preserve directory structure

I would like to make a mac os x app for distributing my program.
The problem is that current script puts "images/Diagram.png" and other files under "images" folder to "Resources" but not to "Resources/images" as expected
What can I change in this setup.py part in order to put png files under images?
mainscript, ico, icns = "aproxim.py", "sum.ico", "sum.icns"
files = ["images/Diagram.png", "images/document.png", "images/Exit.png", "images/floppydisc.png",
"images/folder.png", "images/Info.png", "images/settings.png"]
scripts = ["app_settings_dialog", "app_window", "approximator", "approximator2", "data_format",
"easy_excel", "functions", "main_window", "settings_dialog",
"util_data", "util_parameters"]
description = "Approximator is program for experimental data approximation and interpolation (20 dependencies for select)"
common_options = dict(name = "Approximator", version = "1.7", description = description)
if sys.platform == 'darwin':
setup(
setup_requires = ['py2app'],
app = [mainscript],
options = dict(py2app = dict(includes = scripts, resources = files, iconfile = icns)),
**common_options)
It is easy, hope it is useful for other Python developers:
resources = [('images', files), ('', [ico])]

Django: which search library do you recommend for Windows? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I develop site on Windows, but when I tried to add search, I encountered too many problems with Sphinx and Haystack+Xapian. Possible solution is to go to Linux, but I don't want to change my working environment. What search library/server/etc do you recommend for Windows? Which version, repository, tutorials have you used? Maybe you can wrote your own mini-tutorial? I really frustrated with this problem and cannot step forward for several days.
Finally I got Sphinx to work. Still problems with searching in multiple tables but this is solvable I believe.
Useful links:
How to install and implement Sphinx Search on XAMPP for Windows 7 with MySQL and PHP
Tutorial: Installing on Windows
Installing Sphinx on Windows
In the following snippets paths on my system are used.
Search function in views.py:
def search(request):
from sphinxapi import SphinxClient, SPH_MATCH_ANY, SPH_SORT_RELEVANCE
S = request.GET['search']
client = SphinxClient()
client.SetServer('127.0.0.1', 9312)
#client.SetSelect("*, AVG(price) AS avgprice")
client.SetMatchMode(SPH_MATCH_ANY)
client.SetSortMode(SPH_SORT_RELEVANCE)
client.SetFieldWeights({'header': 20, 'text': 10})
result = client.Query(S, '*')
matches = result["matches"]
ids = [match["id"] for match in matches]
article = {"header": "Search results", "text": ""}
if ids != []:
objects = Main.objects.filter(pk__in = ids)
for object in objects:
url = request.build_absolute_uri(object.get_absolute_url())
article["text"] += "" + object.header + "" + "\n"
ResponseDict = {"articles": [article]}
else:
ResponseDict = {"articles": []}
return render_to_response("index.html", ResponseDict,
context_instance = RequestContext(request))
sphinx.conf (which is in ...\Sphinx\bin folder):
source src1
{
type = pgsql
sql_host = localhost
sql_user = <db user>
sql_pass = <pwd>
sql_db = <db name>
sql_port = 5432
sql_query = \
SELECT id, header, text \
FROM app_main
sql_query_info = SELECT * FROM app_main WHERE id=$id
sql_attr_uint = source_id
}
source src2
{
type = pgsql
sql_host = localhost
sql_user = <db user>
sql_pass = <pwd>
sql_db = <db name>
sql_port = 5432
sql_query = \
SELECT id, header, text \
FROM app_comment
sql_query_info = SELECT * FROM app_comment WHERE id=$id
sql_attr_uint = source_id
}
index test1
{
source = src1
source = src2
path = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/data/test1
docinfo = extern
charset_type = utf-8
}
index testrt
{
type = rt
rt_mem_limit = 32M
path = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/data/testrt
charset_type = utf-8
rt_field = title
rt_field = content
rt_attr_uint = gid
}
indexer
{
mem_limit = 32M
}
searchd
{
listen = 127.0.0.1:9312
log = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/log/searchd.log
query_log = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/log/query.log
read_timeout = 5
max_children = 30
pid_file = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/log/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/data
}
Search is available after creating \sphinx, \sphinx\data and \sphinx\log folders in app folder, indexing with command
D:/Old/Sphinx/bin/indexer --config D:/Old/Sphinx/bin/sphinx.conf --all
and starting searchd with command
D:/Old/Sphinx/bin/searchd --config D:/Old/Sphinx/bin/sphinx.conf