Im trying to test uplading a library to pypi i just made a verry simple one - setuptools

How the folders and files are structured:
all the text in README.txt
This is a verry simple calculator.
all the text in CHANGELOG.txt
Change Log
==========
0.0.1 (19/10/2020)
-------------------
- First Release
all the text in LICENCE.txt (edited out my name with ------- ------)
Copyright 2020 ------- -----
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
all the text in MANIFEST.in
global-include *.txt *.py
all the text in __init__.py
def add_num(num1, num2):
return num1 + num2
def subtract_num(num1, num2):
return num1 - num2
def multiply_num(num1, num2):
return num1 * num2
def divide_num(num1, num2):
return num1 / num2
def exponent_num(num1, num2):
return num1 ** num2
all the test in setup.py (edited out my email and name)
from setuptools import setup, find_packages
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Education',
'Operating System :: Microsoft :: Windows :: Windows 10',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3'
]
setup(
name='martinsimplecalculator',
version='0.0.1',
description='a basic calculator',
long_description_content_type='txt',
long_description=open('README.txt').read() + '\n\n' + open('CHANGELOG.txt').read(),
url='',
author='----',
author_email='----',
license='MIT',
classifiers=classifiers,
keywords='calculator',
packages=find_packages(),
install_requires=['']
)
the rest of the files were made with the command:
python3 setup.py sdist
and after i typed in:
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
and typed in my username and password i got this error:
HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
The description failed to render in the default format of reStructuredText. See https://pypi.org/help/#description-content-type for more information.
please help ive never done this before and ive been folowing this youtube video

The content type txt is not a valid content type, you should use text/plain instead for plaintext:
long_description_content_type='text/plain',
Furthermore, it looks like you're using an old version of setuptools from before long_description_content_type existed, you should upgrade to the latest version:
$ python3 -m pip install -U setuptools

Related

OpenCobol & PostgreSQL on Windows with Visual Studio

I'm currently facing a problem with this team of 4.
Using binaries I downloaded on kiska's site. I'm able to compile cobol to C and run it with cobcrun or compile it to an executable. However I can 't get opencobol to find the postgres commands.
Here is the strat of my cobol script :
identification division.
program-id. pgcob.
data division.
working-storage section.
01 pgconn usage pointer.
01 pgres usage pointer.
01 resptr usage pointer.
01 resstr pic x(80) based.
01 result usage binary-long.
01 answer pic x(80).
procedure division.
display "Before connect:" pgconn end-display
call "PQconnectdb" using
by reference "dbname = postgres" & x"00"
by reference "host = 10.37.180.146" & "00"
returning pgconn
end-call
...
the call PQconnectdb fail with module ont found : PQconnectdb
I noticed that if i rename the libpq.dll the error message change to can't find entry point. So at least I'm sure it can get my dll.
After digging into the code of the call method of the libcob library. I found it it was possible to pre load some dll using an environment variable COB_PRE_LOAD but sitll no results.
Here is what look the script to compile the cobol :
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat"
set COB_CONFIG_DIR=C:\OpenCobol\config
set COB_COPY_DIR=C:\OpenCobol\Copy
set COB_LIBS=%COB_LIBS% c:\OpenCobol\libpq.lib
set COB_LIBRARY_PATH=C:\OpenCobol\bin
set COB_PRE_LOAD=C:\OpenCobol\libpq.dll
#echo on
cobc -info
cobc -free -o pgcob -L:"C:\OpenCobol" -llibpq.lib test_cobol\postgres.cob
call cobcrun pgcob
I don't see anything missing, I'm using the 64-bit binaries from kiska's site and use the 64-bit cl.exe from Visual Studio, Postgres is a 64 bit version too (checked with dependencyChecker).
I even tryed to compile the generated C from Visual Studio, same result, but I may miss something, I'm pretty rotten in C and never really had to manage DLL or use Visual Studio.
What am I missing ?
COB_PRE_LOAD doesn't take any path or extension, see the short documentation for the available runtime configurations. I guess
set COB_LIBRARY_PATH=C:\OpenCobol\bin;C:\OpenCobol
set COB_PRE_LOAD=libpq
Will work. You can omit the C:\OpenCobol\bin if you did not placed any additional executables there.
If it doesn't work (even if it does) I'd try to get the C functions resolved at compile time. Either use
CALL STATIC "PQconnectdb" using ...
or an appropriate CALL-CONVENTION or leave the program as-is and use
cobc -free -o pgcob -L"C:\OpenCobol" -llibpq -K PQconnectdb test_cobol\postgres.cob
From cobc --help:
-K generate CALL to <entry> as static
In general: the binaries from kiska.net are quite outdated. I highly suggest getting newer ones from the official download site or ideally build them on your own from source, see the documentation for building GnuCOBOL with VisualStudio.

sudo /script.py - read out temperature&humidty in .php

I'm currently on a project with my Raspberry Pi B+.
I'm using a DHT22 - Temperature & Humidity Sensor. I'm also using Adafruit that's working together with python.
My Problem is, that I don't really know, how to read out a specific thing in my .php script that I want to implement in a index.php (Apache-Server).
I can read the Temperature & Humidity over putty with:
sudo /root/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 4
while 22 is the DHT "22" Sensor - since there is an older one named "11" and 4 the GPIO of the raspberry.
putty is now telling this:
root#raspberrypi:~# sudo /root/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 4
Temp=21.3* Humidity=41.6%
The AdafruitDHT.py for itself looks like this:
#!/usr/bin/python
# Copyright (c) 2014 Adafruit Industries
# Author: Tony DiCola
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import sys
import Adafruit_DHT
# Parse command line parameters.
sensor_args = { '11': Adafruit_DHT.DHT11,
'22': Adafruit_DHT.DHT22,
'2302': Adafruit_DHT.AM2302 }
if len(sys.argv) == 3 and sys.argv[1] in sensor_args:
sensor = sensor_args[sys.argv[1]]
pin = sys.argv[2]
else:
print('usage: sudo ./Adafruit_DHT.py [11|22|2302] GPIOpin#')
print('example: sudo ./Adafruit_DHT.py 2302 4 - Read from an AM2302 connected to GPIO #4')
sys.exit(1)
# Try to grab a sensor reading. Use the read_retry method which will retry up
# to 15 times to get a sensor reading (waiting 2 seconds between each retry).
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
# Un-comment the line below to convert the temperature to Fahrenheit.
# temperature = temperature * 9/5.0 + 32
# Note that sometimes you won't get a reading and
# the results will be null (because Linux can't
# guarantee the timing of calls to read the sensor).
# If this happens try again!
if humidity is not None and temperature is not None:
print('Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity))
else:
print('Failed to get reading. Try again!')
sys.exit(1)
my .php looks like this:
<?php
$temp = exec('cat /root/Adafruit_Python_DHT/examples/AdafruitDHT.py |grep Temp=');
$temp = explode('Temp=',$temp);
$temp = round($temp,2);
echo $temp;
?>
I know that my first line is not correct like that.
But I don't know how to read out the live-temperature and live-Humidity. And I didn't know what to google for exactly.
edit 1:
with the following .php file, the site looks like this:
`
as you can see, it is only missing the output coming from the DHT22-sensor only.
If you do
cat /root/Adafruit_Python_DHT/examples/AdafruitDHT.py | grep Temp=
you are not running/executing the AdafruitDHT.py program, you are copying it contents (ie. the python program text) So what you will get back from the PHP exec is probably the matching line
print('Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity))
Change that line to:
$temp = exec('python /root/Adafruit_Python_DHT/examples/AdafruitDHT.py | grep Temp=')
after making sure you are allowed to use a pipe (|) in a PHP exec call. (If not consider stripping the output of the script to only that what you want to have in PHP, dropping the | grep .... part).

Ada scheduling in EDF

For some reason this EDF example doesn't compile. I'm using GNAT I tried it in Windows 8.1, Debian no result.
with Ada.Real_Time, ada.Task_Identification,ada.Dispatching.EDF; use Ada.Real_Time, ada.Task_Identification,ada.Dispatching.EDF;
Procedure exemple_ordon is
Task tache_Periodique;
Task body tache_Periodique is
Echeance: Time_Span := Milliseconds(30); heure: Time;
Begin
heure:= Clock; Set_Deadline(Clock + Echeance);
Loop
heure := heure + Echeance;Delay_Until_And_Set_Deadline(heure,Echeance);
end loop;
End tache_Periodique;
Begin Null; End exemple_ordon ;
The error message:
gnatmake -d -PC:\Users\Awk\default.gpr exemple_ordon.adb
gcc -c -g -O2 -I- -gnatA C:\Users\Awk\exemple_ordon.adb
Edf is not supported in this configuration
compilation abandoned
gnatmake: "C:\Users\Awk\exemple_ordon.adb" compilation error
The message Edf is not supported in this configuration tells the story!
I don’t have access to any supported version of GNAT, but the file a-disedf.ads (the spec of Ada.Dispatching.EDF) in FSF GCC 4.9.0 contains the comment
-- This unit is not implemented in typical GNAT implementations that lie on
-- top of operating systems, because it is infeasible to implement in such
-- environments.
-- If a target environment provides appropriate support for this package,
-- then the Unimplemented_Unit pragma should be removed from this spec and
-- an appropriate body provided.
so it’s possible that AdaCore may provide an implementation for some of the more real-time targets (e.g. VxWorks) for their paying customers.
Do you have access to AdaCore’s academic program (GAP)?
If you really need EDF scheduling, Concurrency in Ada by Burns and Wellings has an example (I have the paperback second edition); you can pick it up cheaply at AbeBooks.
If you ‘just’ need information about general tasking, there are several sources listed at the Ada Information Clearinghouse.
Many people developing high-integrity real time software in Ada use the Ravenscar Profile.

TFS Command Line not executing when output redirected

Why is the 'Resolve Conflict' window not showing when i redirect the output to a text file as shown below
d:\tfstest\tf resolve >myfile.txt
It shows when i choose not to redirect the output as follows:
d:\tfstest\tf resolve
Why is this happening????
When you use a redirect it doesn't show UI because using redirects is something you normally do in a script which chains things together. So instead the expectation is that you call tf resolve for each conflict and pass the advanced parameters to tell it how to handle these conflicts (in combination with /noprompt):
Microsoft (R) TF - Team Foundation Version Control Tool, Version
11.0.60315.1 Copyright (c) Microsoft Corporation. All rights reserved.
Resolves conflicts between changed items in your workspace and the
latest or destination versions of items on the server.
tf resolve [itemspec]
[/auto:(AutoMerge|AutoMergeForced|TakeTheirs|KeepYours|
OverwriteLocal|DeleteConflict|KeepYoursRenameTheirs)]
[/preview] [/recursive] [/newname:path] [/noprompt]
[(/overridetype:overridetype | /converttotype:converttype)]
[/properties:(#valuefile|name1=value1[;name2=value2;name3=#valuefile;
...]
[/login:username,[password]]

What is the canonical way to make autoconf link in Solaris network libraries?

On Solaris, when you compile a program that uses sockets, you need to link it with -lnsl -lsocket. Many such programs were originally written for Linux (where no extra libraries are needed), and therefore do not check for these libraries in their configure scripts, even though that is a rather simple addition. Something like this (untested):
AC_SEARCH_LIBS(gethostbyname, nsl, , AC_MSG_ERROR([gethostbyname not found]))
AC_SEARCH_LIBS(connect, socket, , AC_MSG_ERROR([connect not found]))
Is there a canonical way to do this check? Maybe even included in the autoconf distribution? You would imagine that there is a rather widespread need for that, but Google wouldn't tell me.
i think the closest to a canonical way to check this is the AX_LIB_SOCKET_NSL macro from the Autoconf Archive:
# ===========================================================================
# http://www.nongnu.org/autoconf-archive/ax_lib_socket_nsl.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_SOCKET_NSL
#
# DESCRIPTION
#
# This macro figures out what libraries are required on this platform to
# link sockets programs.
#
# The common cases are not to need any extra libraries, or to need
# -lsocket and -lnsl. We need to avoid linking with libnsl unless we need
# it, though, since on some OSes where it isn't necessary it will totally
# break networking. Unisys also includes gethostbyname() in libsocket but
# needs libnsl for socket().
#
# LICENSE
#
# Copyright (c) 2008 Russ Allbery <rra#stanford.edu>
# Copyright (c) 2008 Stepan Kasal <kasal#ucw.cz>
# Copyright (c) 2008 Warren Young <warren#etr-usa.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL])
AC_DEFUN([AX_LIB_SOCKET_NSL],
[
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket], [], [
AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
[], [-lnsl])])
])
I can't remember any finished code off the top of my head, but you usually want to check whether you can link a program calling the gethostbyname() function without any extra libs first. Only if that fails, you want to try the nsl library.
Similar things apply e.g. for the m library.