[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Powerguru-commit] [SCM] powerguru branch, master, updated. 8237d0bc050e
From: |
Rob Savoye |
Subject: |
[Powerguru-commit] [SCM] powerguru branch, master, updated. 8237d0bc050edb3eae6fb8956ca04b1e72d2942b |
Date: |
Sat, 5 Jan 2019 16:29:12 -0500 (EST) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "powerguru".
The branch, master has been updated
via 8237d0bc050edb3eae6fb8956ca04b1e72d2942b (commit)
via d17c55033465daf1eb50ac1d08e79fecf1fba178 (commit)
via cc40fa56225a69d98462d7937122f21b4a0e12d7 (commit)
via 2dd4f791ad2411961d56641fe58d992f50b8c70d (commit)
from 31f9008da3e3309663edf34e743784174c6cafda (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=8237d0bc050edb3eae6fb8956ca04b1e72d2942b
commit 8237d0bc050edb3eae6fb8956ca04b1e72d2942b
Author: Rob Savoye <address@hidden>
Date: Sat Jan 5 14:29:03 2019 -0700
Link to python sources so they're accessible from the build directory
diff --git a/configure.ac b/configure.ac
index 612370f..95cbc6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,7 @@ AC_CONFIG_MACRO_DIR([macros])
dnl Use the DMalloc library, if specified.
AM_WITH_DMALLOC
+AC_PROG_LN_S
dnl Use the Dom parser from libxml2, not the xmlReader one
dnl The default is to use the Dom parser
@@ -464,7 +465,10 @@ AC_ARG_WITH(tty,
dnl link to the images so we can browse the HTML output before
dnl installing it.
+dnl Link to the python code so it's easier to use from the builddir.
AC_LINK_FILES(doc/C/images,doc/C/images)
+AC_LINK_FILES(python,python)
+
AC_OUTPUT([
Makefile
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=d17c55033465daf1eb50ac1d08e79fecf1fba178
commit d17c55033465daf1eb50ac1d08e79fecf1fba178
Author: Rob Savoye <address@hidden>
Date: Sat Jan 5 13:51:48 2019 -0700
Python3 support files
diff --git a/python/requirements.txt b/python/requirements.txt
new file mode 100644
index 0000000..49793d3
--- /dev/null
+++ b/python/requirements.txt
@@ -0,0 +1,4 @@
+subprocess
+psycopg2
+logging
+glob
diff --git a/python/setup.py b/python/setup.py
new file mode 100644
index 0000000..0a8aed1
--- /dev/null
+++ b/python/setup.py
@@ -0,0 +1,12 @@
+from distutils.core import setup
+
+setup(
+ name='PowerGuru',
+ version='0.1',
+ packages=[],
+ url='https://git.savannah.gnu.org/git/powerguru.git',
+ license='GPLv3',
+ author='Rob Savoye',
+ author_email='address@hidden',
+ description='.',
+)
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=cc40fa56225a69d98462d7937122f21b4a0e12d7
commit cc40fa56225a69d98462d7937122f21b4a0e12d7
Author: Rob Savoye <address@hidden>
Date: Sat Jan 5 13:51:18 2019 -0700
Add class for handling postgresql
diff --git a/python/pgdb.py b/python/pgdb.py
new file mode 100644
index 0000000..4a8c3d6
--- /dev/null
+++ b/python/pgdb.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python3
+
+#
+# Copyright (C) 2017, 2018, 2019 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+import pdb
+import glob
+import psycopg2
+import subprocess
+import config
+import logging
+
+## \class pgdb
+# A class to work with a postgresql database
+class pgdb(object):
+ """PostgreSQL database class."""
+ def __init__(self, config):
+ self.config = config
+ self.dbname = ""
+ self.result = ""
+ # self.config.dump()
+
+ def connect(self, dbname):
+ '''Connect to a postgresql server'''
+ logging.debug("plotcalls.connect(" + dbname + ")")
+ self.config.set('dbname', dbname)
+ connect = " dbname=" + dbname
+
+ try:
+ self.dbshell = psycopg2.connect(connect)
+ if self.dbshell.closed == 0:
+ self.dbshell.autocommit = True
+ logging.info("Opened connection to %r %r" % (dbname,
self.dbshell))
+
+ self.dbcursor = self.dbshell.cursor()
+ if self.dbcursor.closed == 0:
+ logging.info("Opened cursor in %r %r" % (dbname,
self.dbcursor))
+
+ except Exception as e:
+ print("Couldn't connect to database: %r" % e)
+
+ def query(self, query, nores=""):
+ '''Query a postgresql database'''
+ logging.debug("plotcalls.query(" + query + ")")
+ try:
+ self.dbcursor.execute(query)
+ self.result = self.dbcursor.fetchall()
+ except:
+ self.result = list()
+ #logging.debug("FIXME: query(%r)" % len(self.result))
+ nores = self.result
+ return self.result
+
+ def shell(self, cmd):
+ cmdline = list()
+ cmdline.append("psql")
+ if len(self.config.get('dbname')) > 0:
+ cmdline.append("--dbname=" + str(self.config.get('dbname')))
+ cmdline.append("--command=" + cmd)
+ self.verbose.log(cmdline)
+ try:
+ subprocess.call(cmdline, stdout=subprocess.DEVNULL)
+ out = True
+ except:
+ self.verbose.warning("Couldn't list function: %r" % func)
+ out = False
+
+ return out
+
+ def dump(self):
+ print("Dumping data from pgdb class")
+ self.list_functions()
+ if self.dbshell.closed == 0:
+ status = "Open"
+ else:
+ status = "Closed"
+ print("Connection: " + status)
+ print("DSN: " + self.dbshell.dsn)
+ print("AutoCommit: " + str(self.dbshell.autocommit))
+ for i in self.dbshell.notices:
+ print("History: " + i.replace('\n', ''))
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=2dd4f791ad2411961d56641fe58d992f50b8c70d
commit 2dd4f791ad2411961d56641fe58d992f50b8c70d
Author: Rob Savoye <address@hidden>
Date: Sat Jan 5 12:42:43 2019 -0700
Dropped, now using boost mutexes
diff --git a/lib/sem.cc b/lib/sem.cc
deleted file mode 100644
index 88b007d..0000000
--- a/lib/sem.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-//
-// Copyright (C) 2005, 2006 - 2018
-// Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-// SysV semaphores
-//
-// key_t ftok(char *pathname, char proj_id);
-// The most commonly used method of generating an IPC key that is
-// reasonably unique.
-//
-// int semget ( key_t key, int nsems, int semflg )
-// The function returns the semaphore set identifier associated
-// to the value of the argument key.
-//
-// int semctl (int semid, int semnum, int cmd, union semun arg)
-// The function performs the control operation specified by
-// cmd on the semaphore set (or on the semnum-th semaphore of
-// the set) identified by semid. The first semaphore of the
-// set is indicated by a value 0 for semnum.
-//
-// int semop ( int semid, struct sembuf *sops, unsigned nsops)
-// The function performs operations on selected members of the
-// semaphore set indicated by semid. Each of the nsops elements
-// in the array pointed to by sops specify an operation to be
-// performed on a semaphore by a struct sembuf including the
-// following members:
-//
-// POSIX semaphores
-//
-// int sem_init(sem_t *sem, int pshared, unsigned int value);
-//
-// * sem points to a semaphore object to initialize
-// * pshared is a flag indicating whether or not the semaphore should
-// be shared with fork()ed processes. LinuxThreads does not currently
-// support shared semaphores
-// * value is an initial value to set the semaphore to
-//
-// int sem_wait(sem_t *sem);
-//
-// * sem_wait blocks until the specified semaphore object's value is
-// greater than zero. it then decrements the semaphore's value by one
-// and returns
-//
-// int sem_trywait(sem_t *sem);
-//
-// * like sem_wait, but returns immediately and does not decrement
-// the semaphore if it is zero
-//
-// int sem_post(sem_t *sem);
-//
-// * increments the value of a semaphore
-//
-// int sem_getvalue(sem_t *sem, int *valp);
-//
-// * gets the current value of sem and places it in the location
-// pointed to by valp
-//
-// int sem_destroy(sem_t *sem);
-//
-// * destroys the semaphore; no threads should be waiting on the
-// semaphore if its destruction is to succeed.
-//
-
-
-#include <cstring>
-#include <map>
-#include "sem.h"
-#include <iostream>
-
-using namespace std;
-
-bool Sem::initialized;
-key_t SysVSem::key;
-int SysVSem::semid;
-string SysVSem::keypath;
-
-Sem::Sem (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
-}
-
-Sem::~Sem (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
-}
-
-int
-Sem::Init (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-Sem::Try (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-Sem::Wait (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-Sem::Destroy (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-Sem::GetValue (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-Sem::Post (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-// SysV style semaphores
-SysVSem::SysVSem (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
-}
-
-SysVSem::~SysVSem (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
-}
-
-int
-SysVSem::Init (void) {
- union semun semopts;
- int i;
-
- key = ftok(".", 's');
-
- if((semid = semget(key, MEMBERS, IPC_CREAT|IPC_EXCL|0666)) == -1) {
- fprintf(stderr, "Semaphore set already exists!\n");
- exit(1);
- }
-
- semopts.val = 1;
-
- /* Initialize all members (could be done with SETALL) */
- for(i=0; i < MEMBERS; i++) {
- semctl(semid, i, SETVAL, semopts);
- }
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-SysVSem::Try (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-SysVSem::Wait (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-SysVSem::Destroy (void) {
- return semctl(semid, 0, IPC_RMID, 0);
-}
-
-int
-SysVSem::GetValue (void) {
- return semctl(semid, MEMBERS, GETVAL, 0);
-}
-
-int
-SysVSem::Post (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-
-// POSIX pthread style semaphores
-POSIXSem::POSIXSem (void) {
- Init();
-}
-
-POSIXSem::~POSIXSem (void) {
- Destroy();
-}
-
-int
-POSIXSem::Init (void) {
- // the middle paramemter must be 0 on Linux, cause process
- // side semaphores aren't supported.
- return sem_init(sem, 0, 1);
-}
-
-int
-POSIXSem::Try (void) {
- // return sem_trywait(sem);
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-POSIXSem::Wait (void) {
- // return sem_wait(sem);
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-POSIXSem::Destroy (void) {
- // return sem_destroy(sem);
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-POSIXSem::GetValue (void) {
- // return sem_getvalue(sem);
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-int
-POSIXSem::Post (void) {
- cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
- return -1;
-}
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: nil
-// End:
diff --git a/lib/sem.h b/lib/sem.h
deleted file mode 100644
index 16b3b1a..0000000
--- a/lib/sem.h
+++ /dev/null
@@ -1,159 +0,0 @@
-//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
-// Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-// SysV semaphores
-//
-// key_t ftok(char *pathname, char proj_id);
-// The most commonly used method of generating an IPC key that is
-// reasonably unique.
-//
-// int semget ( key_t key, int nsems, int semflg )
-// The function returns the semaphore set identifier associated
-// to the value of the argument key.
-//
-// int semctl (int semid, int semnum, int cmd, union semun arg)
-// The function performs the control operation specified by
-// cmd on the semaphore set (or on the semnum-th semaphore of
-// the set) identified by semid. The first semaphore of the
-// set is indicated by a value 0 for semnum.
-//
-// int semop ( int semid, struct sembuf *sops, unsigned nsops)
-// The function performs operations on selected members of the
-// semaphore set indicated by semid. Each of the nsops elements
-// in the array pointed to by sops specify an operation to be
-// performed on a semaphore by a struct sembuf including the
-// following members:
-//
-// POSIX semaphores
-//
-// int sem_init(sem_t *sem, int pshared, unsigned int value);
-//
-// * sem points to a semaphore object to initialize
-// * pshared is a flag indicating whether or not the semaphore should
-// be shared with fork()ed processes. LinuxThreads does not currently
-// support shared semaphores
-// * value is an initial value to set the semaphore to
-//
-// int sem_wait(sem_t *sem);
-//
-// * sem_wait blocks until the specified semaphore object's value is
-// greater than zero. it then decrements the semaphore's value by one
-// and returns
-//
-// int sem_trywait(sem_t *sem);
-//
-// * like sem_wait, but returns immediately and does not decrement
-// the semaphore if it is zero
-//
-// int sem_post(sem_t *sem);
-//
-// * increments the value of a semaphore
-//
-// int sem_getvalue(sem_t *sem, int *valp);
-//
-// * gets the current value of sem and places it in the location
-// pointed to by valp
-//
-// int sem_destroy(sem_t *sem);
-//
-// * destroys the semaphore; no threads should be waiting on the
-// semaphore if its destruction is to succeed.
-//
-
-
-// This shuts up warnings about virtual functions. We don't care,
-// because this isn't implemented yet.
-//#warning "Unimplemented"
-#pragma GCC system_header
-
-extern "C" {
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-
-#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
- /* union semun is defined by including <sys/sem.h> */
-#else
- /* according to X/OPEN we have to define it ourselves */
- union semun {
- int val; /* value for SETVAL */
- struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
- unsigned short int *array; /* array for GETALL, SETALL */
- struct seminfo *__buf; /* buffer for IPC_INFO */
- };
-#endif
-#include <semaphore.h>
-}
-
-#include <cstring>
-#include <map>
-
-#define MEMBERS 1
-
-class Sem {
-private:
- static bool initialized;
- std::map<std::string, int> tbl;
-public:
- Sem (void);
- ~Sem (void);
- virtual int Init (void);
- virtual int Try (void);
- virtual int Wait (void);
- virtual int Destroy (void);
- virtual int GetValue (void);
- virtual int Post (void);
-};
-
-class SysVSem: public Sem {
-private:
- static key_t key;
- static int semid;
- static std::string keypath;
-public:
- SysVSem (void);
- ~SysVSem (void);
- int Init (void);
- int Try (void);
- int Wait (void);
- int Destroy (void);
- int GetValue (void);
- int Post (void);
-};
-
-class POSIXSem: public Sem {
-private:
- sem_t *sem;
-public:
- POSIXSem (void);
- ~POSIXSem (void);
- int Init (void);
- int Try (void);
- int Wait (void);
- int Destroy (void);
- int GetValue (void);
- int Post (void);
-};
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: nil
-// End:
-----------------------------------------------------------------------
Summary of changes:
configure.ac | 4 +
lib/sem.cc | 248 ------------------------------------------------
lib/sem.h | 159 -------------------------------
python/pgdb.py | 95 +++++++++++++++++++
python/requirements.txt | 4 +
python/setup.py | 12 +++
6 files changed, 115 insertions(+), 407 deletions(-)
delete mode 100644 lib/sem.cc
delete mode 100644 lib/sem.h
create mode 100644 python/pgdb.py
create mode 100644 python/requirements.txt
create mode 100644 python/setup.py
hooks/post-receive
--
powerguru
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Powerguru-commit] [SCM] powerguru branch, master, updated. 8237d0bc050edb3eae6fb8956ca04b1e72d2942b,
Rob Savoye <=