Dataset Viewer
Auto-converted to Parquet
content
stringlengths
66
45k
language
stringclasses
11 values
license
stringclasses
14 values
path
stringlengths
20
176
annotation_id
stringlengths
36
36
pii
stringlengths
2
19.6k
pii_modified
stringlengths
2
19.6k
// Copyright (C) 2003 Davis E. King (davis@dlib.net), Miguel Grinberg // License: Boost Software License See LICENSE.txt for the full license. #ifndef DLIB_SOCKETS_KERNEL_2_CPp_ #define DLIB_SOCKETS_KERNEL_2_CPp_ #include "../platform.h" #ifdef POSIX #include "sockets_kernel_2.h" #include <fcntl.h> #include "../set.h" #include <netinet/tcp.h> #define SA_IN(sa) reinterpret_cast<sockaddr_in*>(&sa) #define SA_IN6(sa) reinterpret_cast<sockaddr_in6*>(&sa) namespace dlib { // ---------------------------------------------------------------------------------------- #ifdef HPUX typedef int dsocklen_t; #else typedef socklen_t dsocklen_t; #endif // ---------------------------------------------------------------------------------------- // stuff to ensure that the signal SIGPIPE is ignored before any connections are made // so that when a connection object is shutdown the program won't end on a broken pipe namespace sockets_kernel_2_mutex { mutex startup_lock; } void sockets_startup() { // mutex crap to make this function thread safe sockets_kernel_2_mutex::startup_lock.lock(); static bool init = false; if (init == false) { init = true; signal( SIGPIPE, SIG_IGN); } sockets_kernel_2_mutex::startup_lock.unlock(); } // ---------------------------------------------------------------------------------------- // lookup functions int get_local_hostname ( std::string& hostname ) { try { char temp[MAXHOSTNAMELEN]; if (gethostname(temp,MAXHOSTNAMELEN) == -1) { return OTHER_ERROR; } // ensure that NUL is at the end of the string temp[MAXHOSTNAMELEN-1] = '\0'; hostname = temp; } catch (...) { return OTHER_ERROR; } return 0; } // ----------------- // cygwin currently doesn't support the getaddrinfo stuff #ifndef __CYGWIN__ int hostname_to_ip ( const std::string& hostname, std::string& ip, int n ) { try { set<std::string>::kernel_1a sos; if (hostname.empty()) return OTHER_ERROR; addrinfo* result = 0; if (getaddrinfo(hostname.c_str(),0,0,&result)) { return OTHER_ERROR; } addrinfo* result_orig = result; // loop over all the addrinfo structures and add them to the set. the reason for doing // this dumb crap is because different platforms return all kinds of weird garbage. many // return the same ip multiple times, etc. while (result != 0) { char temp[16]; inet_ntop ( AF_INET, &((reinterpret_cast<sockaddr_in*>(result->ai_addr))->sin_addr), temp,16 ); result = result->ai_next; ip.assign(temp); if (sos.is_member(ip) == false) sos.add(ip); } freeaddrinfo(result_orig); // now return the nth unique ip address int i = 0; while (sos.move_next()) { if (i == n) { ip = sos.element(); return 0; } ++i; } return OTHER_ERROR; } catch (...) { return OTHER_ERROR; } return 0; } // ----------------- int ip_to_hostname ( const std::string& ip, std::string& hostname ) { try { if (ip.empty()) return OTHER_ERROR; sockaddr_in sa; sa.sin_family = AF_INET; inet_pton(AF_INET,ip.c_str(),&sa.sin_addr); char temp[NI_MAXHOST]; if ( getnameinfo ( reinterpret_cast<sockaddr*>(&sa),sizeof(sockaddr_in), temp, NI_MAXHOST, 0, 0, NI_NAMEREQD ) ) { return OTHER_ERROR; } hostname.assign(temp); } catch (...) { return OTHER_ERROR; } return 0; } #else int hostname_to_ip ( const std::string& hostname, std::string& ip, int n ) { try { // lock this mutex since gethostbyname isn't really thread safe auto_mutex M(sockets_kernel_2_mutex::startup_lock); // if no hostname was given then return error if ( hostname.empty()) return OTHER_ERROR; hostent* address; address = gethostbyname(hostname.c_str()); if (address == 0) { return OTHER_ERROR; } // find the nth address in_addr* addr = reinterpret_cast<in_addr*>(address->h_addr_list[0]); for (int i = 1; i <= n; ++i) { addr = reinterpret_cast<in_addr*>(address->h_addr_list[i]); // if there is no nth address then return error if (addr == 0) return OTHER_ERROR; } char* resolved_ip = inet_ntoa(*addr); // check if inet_ntoa returned an error if (resolved_ip == NULL) { return OTHER_ERROR; } ip.assign(resolved_ip); } catch(...) { return OTHER_ERROR; } return 0; } // ----------------- int ip_to_hostname ( const std::string& ip, std::string& hostname ) { try { // lock this mutex since gethostbyaddr isn't really thread safe auto_mutex M(sockets_kernel_2_mutex::startup_lock); // if no ip was given then return error if (ip.empty()) return OTHER_ERROR; hostent* address; unsigned long ipnum = inet_addr(ip.c_str()); // if inet_addr coudln't convert ip then return an error if (ipnum == INADDR_NONE) { return OTHER_ERROR; } address = gethostbyaddr(reinterpret_cast<char*>(&ipnum),4,AF_INET); // check if gethostbyaddr returned an error if (address == 0) { return OTHER_ERROR; } hostname.assign(address->h_name); } catch (...) { return OTHER_ERROR; } return 0; } #endif // __CYGWIN__ // ---------------------------------------------------------------------------------------- connection:: connection( int sock, int foreign_port, const std::string& foreign_ip, int local_port, const std::string& local_ip ) : connection_socket(sock), connection_foreign_port(foreign_port), connection_foreign_ip(foreign_ip), connection_local_port(local_port), connection_local_ip(local_ip), sd(false), sdo(false), sdr(0) {} // ---------------------------------------------------------------------------------------- int connection:: disable_nagle() { int flag = 1; if(setsockopt( connection_socket, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) )) { return OTHER_ERROR; } return 0; } // ---------------------------------------------------------------------------------------- long connection:: write ( const char* buf, long num ) { const long old_num = num; long status; const long max_send_length = 1024*1024*100; while (num > 0) { // Make sure to cap the max value num can take on so that if it is // really large (it might be big on 64bit platforms) so that the OS // can't possibly get upset about it being large. const long length = std::min(max_send_length, num); if ( (status = ::send(connection_socket,buf,length,0)) <=0) { // if send was interupted by a signal then restart it if (errno == EINTR) { continue; } else { // check if shutdown or shutdown_outgoing have been called if (sdo_called()) return SHUTDOWN; else return OTHER_ERROR; } } num -= status; buf += status; } return old_num; } // ---------------------------------------------------------------------------------------- long connection:: read ( char* buf, long num ) { long status; const long max_recv_length = 1024*1024*100; while (true) { // Make sure to cap the max value num can take on so that if it is // really large (it might be big on 64bit platforms) so that the OS // can't possibly get upset about it being large. const long length = std::min(max_recv_length, num); status = recv(connection_socket,buf,length,0); if (status == -1) { // if recv was interupted then try again if (errno == EINTR) continue; else { if (sd_called()) return SHUTDOWN; else return OTHER_ERROR; } } else if (status == 0 && sd_called()) { return SHUTDOWN; } return status; } // while (true) } // ---------------------------------------------------------------------------------------- long connection:: read ( char* buf, long num, unsigned long timeout ) { long status; const long max_recv_length = 1024*1024*100; if (readable(timeout) == false) return TIMEOUT; // Make sure to cap the max value num can take on so that if it is // really large (it might be big on 64bit platforms) so that the OS // can't possibly get upset about it being large. const long length = std::min(max_recv_length, num); status = recv(connection_socket,buf,length,0); if (status == -1) { // if recv was interupted then call this a timeout if (errno == EINTR) { return TIMEOUT; } else { if (sd_called()) return SHUTDOWN; else return OTHER_ERROR; } } else if (status == 0 && sd_called()) { return SHUTDOWN; } return status; } // IPV6 Helpers static inline bool sockaddr_name(sockaddr_storage &sin, std::string &name) { void *addr; if (sin.ss_family == AF_INET6) addr = &(SA_IN6(sin)->sin6_addr); else addr = &(SA_IN(sin)->sin_addr); char buffer[INET6_ADDRSTRLEN]; const char *temp = inet_ntop(sin.ss_family, addr, buffer, INET6_ADDRSTRLEN); if (temp == NULL) return false; name.assign(temp); return true; } static inline int sockaddr_port(sockaddr_storage &sin) { if (sin.ss_family == AF_INET6) return ntohs(SA_IN6(sin)->sin6_port); else return ntohs(SA_IN(sin)->sin_port); } static inline void set_sockaddr_port(sockaddr_storage &sin, int port) { if (sin.ss_family == AF_INET6) SA_IN6(sin)->sin6_port = htons(port); else SA_IN(sin)->sin_port = htons(port); } static inline sa_family_t sockaddr_family(const std::string &ip, dsocklen_t &len) { if (ip.empty() || ip.find(':') == std::string::npos) { len = sizeof(sockaddr_in); return AF_INET; } else { len = sizeof(sockaddr_in6); return AF_INET6; } } static inline bool set_sockaddr_address(sockaddr_storage &sin, const std::string &ip) { void *addr; if (sin.ss_family == AF_INET6) addr = &(SA_IN6(sin)->sin6_addr); else addr = &(SA_IN(sin)->sin_addr); if (inet_pton(sin.ss_family, ip.c_str(), addr) != 1) return false; return true; } static inline void sockaddr_inaddr_any(sockaddr_storage &sin) { if (sin.ss_family == AF_INET6) memcpy(&SA_IN6(sin)->sin6_addr, &in6addr_any, sizeof(in6addr_any)); else SA_IN(sin)->sin_addr.s_addr = htons(INADDR_ANY); } // ---------------------------------------------------------------------------------------- bool connection:: readable ( unsigned long timeout ) const { fd_set read_set; // initialize read_set FD_ZERO(&read_set); // add the listening socket to read_set FD_SET(connection_socket, &read_set); // setup a timeval structure timeval time_to_wait; time_to_wait.tv_sec = static_cast<long>(timeout/1000); time_to_wait.tv_usec = static_cast<long>((timeout%1000)*1000); // wait on select int status = select(connection_socket+1,&read_set,0,0,&time_to_wait); // if select timed out or there was an error if (status <= 0) return false; // socket is ready to be read return true; } // ---------------------------------------------------------------------------------------- connection:: ~connection ( ) { while (true) { int status = ::close(connection_socket); if (status == -1 && errno == EINTR) continue; break; } } // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- // listener object // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- listener:: listener( int sock, int port, const std::string& ip ) : listening_socket(sock), listening_port(port), listening_ip(ip), inaddr_any(listening_ip.empty()) {} // ---------------------------------------------------------------------------------------- listener:: ~listener ( ) { while (true) { int status = ::close(listening_socket); if (status == -1 && errno == EINTR) continue; break; } } // ---------------------------------------------------------------------------------------- int listener:: accept ( scoped_ptr<connection>& new_connection, unsigned long timeout ) { new_connection.reset(0); connection* con; int status = this->accept(con, timeout); if (status == 0) new_connection.reset(con); return status; } // ---------------------------------------------------------------------------------------- int listener:: accept ( connection*& new_connection, unsigned long timeout ) { int incoming; sockaddr_storage incomingAddr; dsocklen_t length = sizeof(sockaddr_storage); // implement timeout with select if timeout is > 0 if (timeout > 0) { fd_set read_set; // initialize read_set FD_ZERO(&read_set); // add the listening socket to read_set FD_SET(listening_socket, &read_set); timeval time_to_wait; // loop on select so if its interupted then we can start it again while (true) { // setup a timeval structure time_to_wait.tv_sec = static_cast<long>(timeout/1000); time_to_wait.tv_usec = static_cast<long>((timeout%1000)*1000); // wait on select int status = select(listening_socket+1,&read_set,0,0,&time_to_wait); // if select timed out if (status == 0) return TIMEOUT; // if select returned an error if (status == -1) { // if select was interupted or the connection was aborted // then go back to select if (errno == EINTR || errno == ECONNABORTED || #ifdef EPROTO errno == EPROTO || #endif errno == ECONNRESET ) { continue; } else { return OTHER_ERROR; } } // accept the new connection incoming=::accept ( listening_socket, reinterpret_cast<sockaddr*>(&incomingAddr), &length ); // if there was an error return OTHER_ERROR if ( incoming == -1 ) { // if accept was interupted then go back to accept if (errno == EINTR || errno == ECONNABORTED || #ifdef EPROTO errno == EPROTO || #endif errno == ECONNRESET ) { continue; } else { return OTHER_ERROR; } } // if there were no errors then quit loop break; } } // else if there is no time out then just go into accept else { while (true) { // call accept to get a new connection incoming=::accept ( listening_socket, reinterpret_cast<sockaddr*>(&incomingAddr), &length ); // if there was an error return OTHER_ERROR if ( incoming == -1 ) { // if accept was interupted then go back to accept if (errno == EINTR || errno == ECONNABORTED || #ifdef EPROTO errno == EPROTO || #endif errno == ECONNRESET ) { continue; } else { return OTHER_ERROR; } } break; } } // get the port of the foreign host into foreign_port int foreign_port = sockaddr_port(incomingAddr); // get the IP of the foreign host into foreign_ip std::string foreign_ip; sockaddr_name(incomingAddr, foreign_ip); // get the local ip for this connection into local_ip std::string local_ip; if (inaddr_any == true) { sockaddr_storage local_info; length = sizeof(sockaddr_in); // get the local sockaddr_in structure associated with this new connection if ( getsockname ( incoming, reinterpret_cast<sockaddr*>(&local_info), &length ) == -1 ) { // an error occurred while (true) { int status = ::close(incoming); if (status == -1 && errno == EINTR) continue; break; } return OTHER_ERROR; } sockaddr_name(local_info, local_ip); } else { local_ip = listening_ip; } // set the SO_OOBINLINE option int flag_value = 1; if (setsockopt(incoming,SOL_SOCKET,SO_OOBINLINE,reinterpret_cast<const void*>(&flag_value),sizeof(int))) { while (true) { int status = ::close(incoming); if (status == -1 && errno == EINTR) continue; break; } return OTHER_ERROR; } // make a new connection object for this new connection try { new_connection = new connection ( incoming, foreign_port, foreign_ip, listening_port, local_ip ); } catch (...) { while (true) { int status = ::close(incoming); if (status == -1 && errno == EINTR) continue; break; } return OTHER_ERROR; } return 0; } // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- // socket creation functions // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- static void close_socket ( int sock ) /*! requires - sock == a socket ensures - sock has been closed !*/ { while (true) { int status = ::close(sock); if (status == -1 && errno == EINTR) continue; break; } } // ---------------------------------------------------------------------------------------- int create_listener ( scoped_ptr<listener>& new_listener, unsigned short port, const std::string& ip ) { new_listener.reset(); listener* temp; int status; status = create_listener(temp,port,ip); if (status == 0) new_listener.reset(temp); return status; } int create_listener ( listener*& new_listener, unsigned short port, const std::string& ip ) { sockets_startup(); sockaddr_storage sas; memset(&sas, 0, sizeof(sockaddr_storage)); // Initialize sas dsocklen_t length; sas.ss_family = sockaddr_family(ip, length); #ifdef __APPLE__ sas.ss_len = length; #endif int sock = socket (sas.ss_family, SOCK_STREAM, 0); // get a new socket // if socket() returned an error then return OTHER_ERROR if (sock == -1) { return OTHER_ERROR; } set_sockaddr_port(sas, port); // set the local socket structure if (ip.empty()) { // if the listener should listen on any IP sockaddr_inaddr_any(sas); } else { // if there is a specific ip to listen on // if inet_addr couldn't convert the ip then return an error if (!set_sockaddr_address(sas, ip)) { close_socket(sock); return OTHER_ERROR; } } // set the SO_REUSEADDR option int flag_value = 1; if (setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,reinterpret_cast<const void*>(&flag_value),sizeof(int))) { close_socket(sock); return OTHER_ERROR; } // bind the new socket to the requested port and ip if (bind(sock,reinterpret_cast<sockaddr*>(&sas), length) == -1) { // if there was an error close_socket(sock); // if the port is already bound then return PORTINUSE if (errno == EADDRINUSE) return PORTINUSE; else return OTHER_ERROR; } // tell the new socket to listen if ( listen(sock,SOMAXCONN) == -1) { // if there was an error return OTHER_ERROR close_socket(sock); // if the port is already bound then return PORTINUSE if (errno == EADDRINUSE) return PORTINUSE; else return OTHER_ERROR; } // determine the used local port if necessary if (port == 0) { sockaddr_storage local_info; if ( getsockname( sock, reinterpret_cast<sockaddr*>(&local_info), &length ) == -1) { close_socket(sock); return OTHER_ERROR; } port = sockaddr_port(local_info); } // initialize a listener object on the heap with the new socket try { new_listener = new listener(sock,port,ip); } catch(...) { close_socket(sock); return OTHER_ERROR; } return 0; } // ---------------------------------------------------------------------------------------- int create_connection ( scoped_ptr<connection>& new_connection, unsigned short foreign_port, const std::string& foreign_ip, unsigned short local_port, const std::string& local_ip ) { new_connection.reset(); connection* temp; int status = create_connection(temp,foreign_port, foreign_ip, local_port, local_ip); if (status == 0) new_connection.reset(temp); return status; } int create_connection ( connection*& new_connection, unsigned short foreign_port, const std::string& foreign_ip, unsigned short local_port, const std::string& local_ip ) { sockets_startup(); dsocklen_t length; sa_family_t family = sockaddr_family(foreign_ip, length); sockaddr_storage local_sa; // local socket structure sockaddr_storage foreign_sa; // foreign socket structure memset(&local_sa,'\0',sizeof(sockaddr_storage)); // initialize local_sa memset(&foreign_sa,'\0',sizeof(sockaddr_storage)); // initialize foreign_sa #ifdef __APPLE__ local_sa.ss_len = foreign_sa.ss_len = length; #endif int sock = socket (family, SOCK_STREAM, 0); // get a new socket // if socket() returned an error then return OTHER_ERROR if (sock == -1 ) { return OTHER_ERROR; } // set up the local and foreign socket structure local_sa.ss_family = family; foreign_sa.ss_family = family; set_sockaddr_port(foreign_sa, foreign_port); set_sockaddr_port(local_sa, local_port); if (!set_sockaddr_address(foreign_sa, foreign_ip)) { close_socket(sock); return OTHER_ERROR; } // set the local ip if (local_ip.empty()) { // if the listener should listen on any IP sockaddr_inaddr_any(local_sa); } else { // if there is a specific ip to listen on // if inet_addr couldn't convert the ip then return an error if (!set_sockaddr_address(local_sa, local_ip)) { close_socket(sock); return OTHER_ERROR; } } // bind the new socket to the requested local port and local ip if ( bind(sock,reinterpret_cast<sockaddr*>(&local_sa), length) == -1) { // if there was an error close_socket(sock); // if the port is already bound then return PORTINUSE if (errno == EADDRINUSE) return PORTINUSE; else return OTHER_ERROR; } // connect the socket if ( connect ( sock, reinterpret_cast<sockaddr*>(&foreign_sa), length ) == -1 ) { close_socket(sock); // if the port is already bound then return PORTINUSE if (errno == EADDRINUSE) return PORTINUSE; else return OTHER_ERROR; } // determine the local port and IP and store them in used_local_ip // and used_local_port int used_local_port = local_port; std::string used_local_ip = local_ip; sockaddr_storage local_info; // determine the port if (local_port == 0 || local_ip.empty()) { length = sizeof(sockaddr_storage); if ( getsockname( sock, reinterpret_cast<sockaddr*>(&local_info), &length ) == -1) { close_socket(sock); return OTHER_ERROR; } if (local_port == 0) used_local_port = sockaddr_port(local_info); if (local_ip.empty()) { if (!sockaddr_name(local_info, used_local_ip)) { close_socket(sock); return OTHER_ERROR; } } } // set the SO_OOBINLINE option int flag_value = 1; if (setsockopt(sock,SOL_SOCKET,SO_OOBINLINE,reinterpret_cast<const void*>(&flag_value),sizeof(int))) { close_socket(sock); return OTHER_ERROR; } // initialize a connection object on the heap with the new socket try { new_connection = new connection ( sock, foreign_port, foreign_ip, used_local_port, used_local_ip ); } catch(...) {close_socket(sock); return OTHER_ERROR; } return 0; } // ---------------------------------------------------------------------------------------- } #endif // POSIX #endif // DLIB_SOCKETS_KERNEL_2_CPp_
C++
Apache-2.0
JITbase/mtconnect-cppagent/lib/dlib/sockets/sockets_kernel_2.cpp
04f66c12-f51a-4f75-9206-5f67989b30a0
[{"tag": "EMAIL", "value": "davis@dlib.net", "start": 38, "end": 52, "context": "// Copyright (C) 2003 Davis E. King (davis@dlib.net), Miguel Grinberg\n// License: Boost Software Lice"}, {"tag": "NAME", "value": "Davis E. King", "start": 23, "end": 36, "context": "// Copyright (C) 2003 Davis E. King (davis@dlib.net), Miguel Grinberg\n// License: Boo"}, {"tag": "NAME", "value": "Miguel Grinberg", "start": 55, "end": 70, "context": "pyright (C) 2003 Davis E. King (davis@dlib.net), Miguel Grinberg\n// License: Boost Software License See LICENSE."}]
[{"tag": "EMAIL", "value": "davis@dlib.net", "start": 38, "end": 52, "context": "// Copyright (C) 2003 Davis E. King (davis@dlib.net), Miguel Grinberg\n// License: Boost Software Lice"}, {"tag": "NAME", "value": "Davis E. King", "start": 23, "end": 36, "context": "// Copyright (C) 2003 Davis E. King (davis@dlib.net), Miguel Grinberg\n// License: Boo"}, {"tag": "NAME", "value": "Miguel Grinberg", "start": 55, "end": 70, "context": "pyright (C) 2003 Davis E. King (davis@dlib.net), Miguel Grinberg\n// License: Boost Software License See LICENSE."}]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the Microsoft Internet Explorer WebCache database.""" import unittest from plaso.lib import definitions from plaso.parsers.esedb_plugins import msie_webcache from tests.parsers.esedb_plugins import test_lib class MsieWebCacheESEDBPluginTest(test_lib.ESEDBPluginTestCase): """Tests for the MSIE WebCache ESE database plugin.""" # pylint: disable=protected-access def testConvertHeadersValues(self): """Tests the _ConvertHeadersValues function.""" plugin = msie_webcache.MsieWebCacheESEDBPlugin() binary_value = ( b'HTTP/1.1 200 OK\r\nContent-Type: image/png\r\n' b'X-Content-Type-Options: nosniff\r\nContent-Length: 2759\r\n' b'X-XSS-Protection: 1; mode=block\r\n' b'Alternate-Protocol: 80:quic\r\n\r\n') expected_headers_value = ( '[HTTP/1.1 200 OK; Content-Type: image/png; ' 'X-Content-Type-Options: nosniff; Content-Length: 2759; ' 'X-XSS-Protection: 1; mode=block; ' 'Alternate-Protocol: 80:quic]') headers_value = plugin._ConvertHeadersValues(binary_value) self.assertEqual(headers_value, expected_headers_value) def testProcessOnDatabaseWithPartitionsTable(self): """Tests the Process function on database with a Partitions table.""" plugin = msie_webcache.MsieWebCacheESEDBPlugin() storage_writer = self._ParseESEDBFileWithPlugin(['WebCacheV01.dat'], plugin) self.assertEqual(storage_writer.number_of_events, 1372) self.assertEqual(storage_writer.number_of_extraction_warnings, 0) self.assertEqual(storage_writer.number_of_recovery_warnings, 0) # The order in which ESEDBPlugin._GetRecordValues() generates events is # nondeterministic hence we sort the events. events = list(storage_writer.GetSortedEvents()) expected_event_values = { 'container_identifier': 1, 'data_type': 'msie:webcache:containers', 'date_time': '2014-05-12 07:30:25.4861987', 'directory': ( 'C:\\Users\\test\\AppData\\Local\\Microsoft\\Windows\\' 'INetCache\\IE\\'), 'name': 'Content', 'set_identifier': 0, 'timestamp_desc': definitions.TIME_DESCRIPTION_LAST_ACCESS} self.CheckEventValues(storage_writer, events[573], expected_event_values) def testProcessOnDatabaseWithPartitionsExTable(self): """Tests the Process function on database with a PartitionsEx table.""" plugin = msie_webcache.MsieWebCacheESEDBPlugin() storage_writer = self._ParseESEDBFileWithPlugin( ['PartitionsEx-WebCacheV01.dat'], plugin) self.assertEqual(storage_writer.number_of_events, 4200) self.assertEqual(storage_writer.number_of_extraction_warnings, 3) self.assertEqual(storage_writer.number_of_recovery_warnings, 0) # The order in which ESEDBPlugin._GetRecordValues() generates events is # nondeterministic hence we sort the events. events = list(storage_writer.GetSortedEvents()) expected_event_values = { 'access_count': 5, 'cache_identifier': 0, 'cached_file_size': 726, 'cached_filename': 'b83d57c0[1].svg', 'container_identifier': 14, 'data_type': 'msie:webcache:container', 'date_time': '2019-03-20 17:22:14.0000000', 'entry_identifier': 63, 'sync_count': 0, 'response_headers': ( '[HTTP/1.1 200; content-length: 726; content-type: image/svg+xml; ' 'x-cache: TCP_HIT; x-msedge-ref: Ref A: 3CD5FCBC8EAD4E0A80FA41A62' 'FBC8CCC Ref B: PRAEDGE0910 Ref C: 2019-12-16T20:55:28Z; date: ' 'Mon, 16 Dec 2019 20:55:28 GMT]'), 'timestamp_desc': definitions.TIME_DESCRIPTION_MODIFICATION, 'url': 'https://www.bing.com/rs/3R/kD/ic/878ca0cd/b83d57c0.svg'} self.CheckEventValues(storage_writer, events[100], expected_event_values) if __name__ == '__main__': unittest.main()
Python
Apache-2.0
ColdSmoke627/plaso/tests/parsers/esedb_plugins/msie_webcache.py
2bf58674-eadf-464d-980d-8a843399c181
[]
[]
=begin #Cisco Intersight #Cisco Intersight is a management platform delivered as a service with embedded analytics for your Cisco and 3rd party IT infrastructure. This platform offers an intelligent level of management that enables IT organizations to analyze, simplify, and automate their environments in more advanced ways than the prior generations of tools. Cisco Intersight provides an integrated and intuitive management experience for resources in the traditional data center as well as at the edge. With flexible deployment options to address complex security needs, getting started with Intersight is quick and easy. Cisco Intersight has deep integration with Cisco UCS and HyperFlex systems allowing for remote deployment, configuration, and ongoing maintenance. The model-based deployment works for a single system in a remote location or hundreds of systems in a data center and enables rapid, standardized configuration and deployment. It also streamlines maintaining those systems whether you are working with small or very large configurations. The Intersight OpenAPI document defines the complete set of properties that are returned in the HTTP response. From that perspective, a client can expect that no additional properties are returned, unless these properties are explicitly defined in the OpenAPI document. However, when a client uses an older version of the Intersight OpenAPI document, the server may send additional properties because the software is more recent than the client. In that case, the client may receive properties that it does not know about. Some generated SDKs perform a strict validation of the HTTP response body against the OpenAPI document. This document was created on 2021-10-20T11:22:53Z. The version of the OpenAPI document: 1.0.9-4870 Contact: intersight@cisco.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 =end require 'spec_helper' require 'json' require 'date' # Unit tests for IntersightClient::KubernetesConfigResultListAllOf # Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe IntersightClient::KubernetesConfigResultListAllOf do let(:instance) { IntersightClient::KubernetesConfigResultListAllOf.new } describe 'test an instance of KubernetesConfigResultListAllOf' do it 'should create an instance of KubernetesConfigResultListAllOf' do expect(instance).to be_instance_of(IntersightClient::KubernetesConfigResultListAllOf) end end describe 'test attribute "count"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end describe 'test attribute "results"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end end
Ruby
Apache-2.0
xlab-si/intersight-sdk-ruby/spec/models/kubernetes_config_result_list_all_of_spec.rb
68e540f7-1f5f-4e34-badd-1c96aea1d6ac
[{"tag": "EMAIL", "value": "intersight@cisco.com", "start": 1797, "end": 1817, "context": "sion of the OpenAPI document: 1.0.9-4870\nContact: intersight@cisco.com\nGenerated by: https://openapi-generator.tech\nOpen"}]
[{"tag": "EMAIL", "value": "intersight@cisco.com", "start": 1797, "end": 1817, "context": "sion of the OpenAPI document: 1.0.9-4870\nContact: intersight@cisco.com\nGenerated by: https://openapi-generator.tech\nOpen"}]
<?php /** * PickListItemModel * * PHP version 5 * * @category Class * @package FrankHouweling\AzureDevOpsClient\ProcessDefinitions * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ /** * WorkItemTracking * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * OpenAPI spec version: 4.1-preview * Contact: nugetvss@microsoft.com * Generated by: https://github.com/swagger-api/swagger-codegen.git * Swagger Codegen version: 2.4.11-SNAPSHOT */ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ namespace FrankHouweling\AzureDevOpsClient\ProcessDefinitions\Model; use \ArrayAccess; use \FrankHouweling\AzureDevOpsClient\ProcessDefinitions\ObjectSerializer; /** * PickListItemModel Class Doc Comment * * @category Class * @description * @package FrankHouweling\AzureDevOpsClient\ProcessDefinitions * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ class PickListItemModel implements ModelInterface, ArrayAccess { const DISCRIMINATOR = null; /** * The original name of the model. * * @var string */ protected static $swaggerModelName = 'PickListItemModel'; /** * Array of property to type mappings. Used for (de)serialization * * @var string[] */ protected static $swaggerTypes = [ 'id' => 'string', 'value' => 'string' ]; /** * Array of property to format mappings. Used for (de)serialization * * @var string[] */ protected static $swaggerFormats = [ 'id' => 'uuid', 'value' => null ]; /** * Array of property to type mappings. Used for (de)serialization * * @return array */ public static function swaggerTypes() { return self::$swaggerTypes; } /** * Array of property to format mappings. Used for (de)serialization * * @return array */ public static function swaggerFormats() { return self::$swaggerFormats; } /** * Array of attributes where the key is the local name, * and the value is the original name * * @var string[] */ protected static $attributeMap = [ 'id' => 'id', 'value' => 'value' ]; /** * Array of attributes to setter functions (for deserialization of responses) * * @var string[] */ protected static $setters = [ 'id' => 'setId', 'value' => 'setValue' ]; /** * Array of attributes to getter functions (for serialization of requests) * * @var string[] */ protected static $getters = [ 'id' => 'getId', 'value' => 'getValue' ]; /** * Array of attributes where the key is the local name, * and the value is the original name * * @return array */ public static function attributeMap() { return self::$attributeMap; } /** * Array of attributes to setter functions (for deserialization of responses) * * @return array */ public static function setters() { return self::$setters; } /** * Array of attributes to getter functions (for serialization of requests) * * @return array */ public static function getters() { return self::$getters; } /** * The original name of the model. * * @return string */ public function getModelName() { return self::$swaggerModelName; } /** * Associative array for storing property values * * @var mixed[] */ protected $container = []; /** * Constructor * * @param mixed[] $data Associated array of property values * initializing the model */ public function __construct(array $data = null) { $this->container['id'] = isset($data['id']) ? $data['id'] : null; $this->container['value'] = isset($data['value']) ? $data['value'] : null; } /** * Show all the invalid properties with reasons. * * @return array invalid properties with reasons */ public function listInvalidProperties() { $invalidProperties = []; return $invalidProperties; } /** * Validate all the properties in the model * return true if all passed * * @return bool True if all properties are valid */ public function valid() { return count($this->listInvalidProperties()) === 0; } /** * Gets id * * @return string */ public function getId() { return $this->container['id']; } /** * Sets id * * @param string $id id * * @return $this */ public function setId($id) { $this->container['id'] = $id; return $this; } /** * Gets value * * @return string */ public function getValue() { return $this->container['value']; } /** * Sets value * * @param string $value value * * @return $this */ public function setValue($value) { $this->container['value'] = $value; return $this; } /** * Returns true if offset exists. False otherwise. * * @param integer $offset Offset * * @return boolean */ public function offsetExists($offset) { return isset($this->container[$offset]); } /** * Gets offset. * * @param integer $offset Offset * * @return mixed */ public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; } /** * Sets value based on offset. * * @param integer $offset Offset * @param mixed $value Value to be set * * @return void */ public function offsetSet($offset, $value) { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } /** * Unsets offset. * * @param integer $offset Offset * * @return void */ public function offsetUnset($offset) { unset($this->container[$offset]); } /** * Gets the string presentation of the object * * @return string */ public function __toString() { if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode( ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT ); } return json_encode(ObjectSerializer::sanitizeForSerialization($this)); } }
PHP
MIT
FrankHouweling/AzureDevOpsClient/lib/AzureDevOpsClient/ProcessDefinitions/Model/PickListItemModel.php
6ad50af0-39fc-4ecf-bde1-da5aac36e60a
[{"tag": "EMAIL", "value": "nugetvss@microsoft.com", "start": 421, "end": 443, "context": "\n * OpenAPI spec version: 4.1-preview\n * Contact: nugetvss@microsoft.com\n * Generated by: https://github.com/swagger-api/s"}]
[{"tag": "EMAIL", "value": "nugetvss@microsoft.com", "start": 421, "end": 443, "context": "\n * OpenAPI spec version: 4.1-preview\n * Contact: nugetvss@microsoft.com\n * Generated by: https://github.com/swagger-api/s"}]
// Code generated by smithy-go-codegen DO NOT EDIT. package managedblockchain import ( "context" "fmt" awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/aws-sdk-go-v2/service/managedblockchain/types" smithy "github.com/awslabs/smithy-go" "github.com/awslabs/smithy-go/middleware" smithyhttp "github.com/awslabs/smithy-go/transport/http" ) // Creates a proposal for a change to the network that other members of the network // can vote on, for example, a proposal to add a new member to the network. Any // member can create a proposal. func (c *Client) CreateProposal(ctx context.Context, params *CreateProposalInput, optFns ...func(*Options)) (*CreateProposalOutput, error) { stack := middleware.NewStack("CreateProposal", smithyhttp.NewStackRequest) options := c.options.Copy() for _, fn := range optFns { fn(&options) } addawsRestjson1_serdeOpCreateProposalMiddlewares(stack) awsmiddleware.AddRequestInvocationIDMiddleware(stack) smithyhttp.AddContentLengthMiddleware(stack) addResolveEndpointMiddleware(stack, options) v4.AddComputePayloadSHA256Middleware(stack) addRetryMiddlewares(stack, options) addHTTPSignerV4Middleware(stack, options) awsmiddleware.AddAttemptClockSkewMiddleware(stack) addClientUserAgent(stack) smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) smithyhttp.AddCloseResponseBodyMiddleware(stack) addIdempotencyToken_opCreateProposalMiddleware(stack, options) addOpCreateProposalValidationMiddleware(stack) stack.Initialize.Add(newServiceMetadataMiddleware_opCreateProposal(options.Region), middleware.Before) addRequestIDRetrieverMiddleware(stack) addResponseErrorMiddleware(stack) for _, fn := range options.APIOptions { if err := fn(stack); err != nil { return nil, err } } handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) result, metadata, err := handler.Handle(ctx, params) if err != nil { return nil, &smithy.OperationError{ ServiceID: ServiceID, OperationName: "CreateProposal", Err: err, } } out := result.(*CreateProposalOutput) out.ResultMetadata = metadata return out, nil } type CreateProposalInput struct { // The type of actions proposed, such as inviting a member or removing a member. // The types of Actions in a proposal are mutually exclusive. For example, a // proposal with Invitations actions cannot also contain Removals actions. // // This member is required. Actions *types.ProposalActions // A unique, case-sensitive identifier that you provide to ensure the idempotency // of the operation. An idempotent operation completes no more than one time. This // identifier is required only if you make a service request directly using an HTTP // client. It is generated automatically if you use an AWS SDK or the AWS CLI. // // This member is required. ClientRequestToken *string // The unique identifier of the member that is creating the proposal. This // identifier is especially useful for identifying the member making the proposal // when multiple members exist in a single AWS account. // // This member is required. MemberId *string // The unique identifier of the network for which the proposal is made. // // This member is required. NetworkId *string // A description for the proposal that is visible to voting members, for example, // "Proposal to add Example Corp. as member." Description *string } type CreateProposalOutput struct { // The unique identifier of the proposal. ProposalId *string // Metadata pertaining to the operation's result. ResultMetadata middleware.Metadata } func addawsRestjson1_serdeOpCreateProposalMiddlewares(stack *middleware.Stack) { stack.Serialize.Add(&awsRestjson1_serializeOpCreateProposal{}, middleware.After) stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateProposal{}, middleware.After) } type idempotencyToken_initializeOpCreateProposal struct { tokenProvider IdempotencyTokenProvider } func (*idempotencyToken_initializeOpCreateProposal) ID() string { return "OperationIdempotencyTokenAutoFill" } func (m *idempotencyToken_initializeOpCreateProposal) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( out middleware.InitializeOutput, metadata middleware.Metadata, err error, ) { if m.tokenProvider == nil { return next.HandleInitialize(ctx, in) } input, ok := in.Parameters.(*CreateProposalInput) if !ok { return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateProposalInput ") } if input.ClientRequestToken == nil { t, err := m.tokenProvider.GetIdempotencyToken() if err != nil { return out, metadata, err } input.ClientRequestToken = &t } return next.HandleInitialize(ctx, in) } func addIdempotencyToken_opCreateProposalMiddleware(stack *middleware.Stack, cfg Options) { stack.Initialize.Add(&idempotencyToken_initializeOpCreateProposal{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) } func newServiceMetadataMiddleware_opCreateProposal(region string) awsmiddleware.RegisterServiceMetadata { return awsmiddleware.RegisterServiceMetadata{ Region: region, ServiceID: ServiceID, SigningName: "managedblockchain", OperationName: "CreateProposal", } }
GO
Apache-2.0
zparnold/aws-sdk-go-v2/service/managedblockchain/api_op_CreateProposal.go
7dc436c5-0f87-4c9b-90e1-6d8cfc674d5c
[]
[]
<?php defined('BASEPATH') or exit('No direct script access allowed'); /* * ============================================================================== * Author : Sheik * Email : info@srampos.com * For : SRAM POS * Web : http://srammram.com * ============================================================================== */ class Gst { public function __construct() { } public function __get($var) { return get_instance()->$var; } function summary($rows = [], $return_rows = [], $product_tax = 0, $onCost = false) { $code = ''; if ($this->Settings->invoice_view > 0 && !empty($rows)) { $tax_summary = $this->taxSummary($rows, $onCost); if (!empty($return_rows)) { $return_tax_summary = $this->taxSummary($return_rows, $onCost); $tax_summary = $tax_summary + $return_tax_summary; } $code = $this->genHTML($tax_summary, $product_tax); } return $code; } function taxSummary($rows = [], $onCost = false) { $tax_summary = []; if (!empty($rows)) { foreach ($rows as $row) { if (isset($tax_summary[$row->tax_code])) { $tax_summary[$row->tax_code]['items'] += $row->unit_quantity; $tax_summary[$row->tax_code]['tax'] += $row->item_tax; $tax_summary[$row->tax_code]['amt'] += ($row->unit_quantity * ($onCost ? $row->net_unit_cost : $row->net_unit_price)) - $row->item_discount; } else { $tax_summary[$row->tax_code]['items'] = $row->unit_quantity; $tax_summary[$row->tax_code]['tax'] = $row->item_tax; $tax_summary[$row->tax_code]['amt'] = ($row->unit_quantity * ($onCost ? $row->net_unit_cost : $row->net_unit_price)) - $row->item_discount; $tax_summary[$row->tax_code]['name'] = $row->tax_name; $tax_summary[$row->tax_code]['code'] = $row->tax_code; $tax_summary[$row->tax_code]['rate'] = $row->tax_rate; } } } return $tax_summary; } function genHTML($tax_summary = [], $product_tax = 0) { $html = ''; if (!empty($tax_summary)) { $html .= '<h4 style="font-weight:bold;">' . lang('tax_summary') . '</h4>'; $html .= '<table class="table table-bordered table-striped print-table order-table table-condensed"><thead><tr><th>' . lang('name') . '</th><th>' . lang('code') . '</th><th>' . lang('qty') . '</th><th>' . lang('tax_excl') . '</th><th>' . lang('tax_amt') . '</th></tr></td><tbody>'; foreach ($tax_summary as $summary) { $html .= '<tr><td>' . $summary['name'] . '</td><td class="text-center">' . $summary['code'] . '</td><td class="text-center">' . $this->sma->formatQuantity($summary['items']) . '</td><td class="text-right">' . $this->sma->formatMoney($summary['amt']) . '</td><td class="text-right">' . $this->sma->formatMoney($summary['tax']) . '</td></tr>'; } $html .= '</tbody></tfoot>'; $html .= '<tr class="active"><th colspan="4" class="text-right">' . lang('total_tax_amount') . '</th><th class="text-right">' . $this->sma->formatMoney($product_tax) . '</th></tr>'; $html .= '</tfoot></table>'; } return $html; } function calculteIndianGST($item_tax, $state, $tax_details) { if ($this->Settings->indian_gst) { $cgst = $sgst = $igst = 0; if ($state) { $gst = $tax_details->type == 1 ? $this->sma->formatDecimal(($tax_details->rate/2), 0).'%' : $this->sma->formatDecimal(($tax_details->rate/2), 0); $cgst = $this->sma->formatDecimal(($item_tax / 2), 4); $sgst = $this->sma->formatDecimal(($item_tax / 2), 4); } else { $gst = $tax_details->type == 1 ? $this->sma->formatDecimal(($tax_details->rate), 0).'%' : $this->sma->formatDecimal(($tax_details->rate), 0); $igst = $item_tax; } return ['gst' => $gst, 'cgst' => $cgst, 'sgst' => $sgst, 'igst' => $igst]; } return []; } function getIndianStates($blank = false) { $istates = [ 'AN' => 'Andaman & Nicobar', 'AP' => 'Andhra Pradesh', 'AR' => 'Arunachal Pradesh', 'AS' => 'Assam', 'BR' => 'Bihar', 'CH' => 'Chandigarh', 'CT' => 'Chhattisgarh', 'DN' => 'Dadra and Nagar Haveli', 'DD' => 'Daman & Diu', 'DL' => 'Delhi', 'GA' => 'Goa', 'GJ' => 'Gujarat', 'HR' => 'Haryana', 'HP' => 'Himachal Pradesh', 'JK' => 'Jammu & Kashmir', 'JH' => 'Jharkhand', 'KA' => 'Karnataka', 'KL' => 'Kerala', 'LD' => 'Lakshadweep', 'MP' => 'Madhya Pradesh', 'MH' => 'Maharashtra', 'MN' => 'Manipur', 'ML' => 'Meghalaya', 'MZ' => 'Mizoram', 'NL' => 'Nagaland', 'OR' => 'Odisha', 'PY' => 'Puducherry', 'PB' => 'Punjab', 'RJ' => 'Rajasthan', 'SK' => 'Sikkim', 'TN' => 'Tamil Nadu', 'TR' => 'Tripura', 'UK' => 'Uttarakhand', 'UP' => 'Uttar Pradesh', 'WB' => 'West Bengal', ]; if ($blank) { array_unshift($istates, lang('select')); } return $istates; } }
PHP
MIT
srammram/Bhaktamar/application/libraries/Gst.php
74a8813b-de64-4e23-97d2-513b5e6bbdf0
[{"tag": "NAME", "value": "Sheik", "start": 173, "end": 178, "context": "=================================\n * Author : Sheik\n * Email : info@srampos.com\n * For : "}, {"tag": "EMAIL", "value": "info@srampos.com", "start": 195, "end": 211, "context": "===========\n * Author : Sheik\n * Email : info@srampos.com\n * For : SRAM POS\n * Web : http://s"}]
[{"tag": "NAME", "value": "Sheik", "start": 173, "end": 178, "context": "=================================\n * Author : Sheik\n * Email : info@srampos.com\n * For : "}, {"tag": "EMAIL", "value": "info@srampos.com", "start": 195, "end": 211, "context": "===========\n * Author : Sheik\n * Email : info@srampos.com\n * For : SRAM POS\n * Web : http://s"}]
# @dusk-network/pagination ## 5.0.5 ### Patch Changes - 8bd8843d: Release - Updated dependencies [8bd8843d] - @dusk-network/icon@5.0.5 - @dusk-network/helpers@5.0.5 - @dusk-network/button@5.0.5 - @dusk-network/menu@5.0.5 ## 5.0.4 ### Patch Changes - fc9a835e: Release - Updated dependencies [fc9a835e] - @dusk-network/icon@5.0.4 - @dusk-network/helpers@5.0.4 - @dusk-network/button@5.0.4 - @dusk-network/menu@5.0.4 ## 5.0.3 ### Patch Changes - d19e01e9: Release - Updated dependencies [d19e01e9] - @dusk-network/icon@5.0.3 - @dusk-network/helpers@5.0.3 - @dusk-network/button@5.0.3 - @dusk-network/menu@5.0.3 ## 5.0.2 ### Patch Changes - bd6220d3: Release - Updated dependencies [bd6220d3] - @dusk-network/icon@5.0.2 - @dusk-network/helpers@5.0.2 - @dusk-network/button@5.0.2 - @dusk-network/menu@5.0.2 ## 5.0.1 ### Patch Changes - f47dbc9c: Release - Updated dependencies [f47dbc9c] - @dusk-network/icon@5.0.1 - @dusk-network/helpers@5.0.1 - @dusk-network/button@5.0.1 - @dusk-network/menu@5.0.1 ## 5.0.0 ### Minor Changes - 5a02600a: Release ### Patch Changes - Updated dependencies [5a02600a] - @dusk-network/icon@5.0.0 - @dusk-network/helpers@5.0.0 - @dusk-network/button@5.0.0 - @dusk-network/menu@5.0.0 ## 4.6.12 ### Patch Changes - 7e97eb52: Release 4.6.12 - Updated dependencies [7e97eb52] - @dusk-network/icon@4.6.12 - @dusk-network/helpers@4.6.12 - @dusk-network/button@4.6.12 - @dusk-network/menu@4.6.12 ## 4.6.11 ### Patch Changes - 771245ec: Release - Updated dependencies [771245ec] - @dusk-network/icon@4.6.11 - @dusk-network/helpers@4.6.11 - @dusk-network/button@4.6.11 - @dusk-network/menu@4.6.11 ## 4.6.10 ### Patch Changes - 85081744: Release - Updated dependencies [85081744] - @dusk-network/icon@4.6.10 - @dusk-network/helpers@4.6.10 - @dusk-network/button@4.6.10 - @dusk-network/menu@4.6.10 ## 4.6.9 ### Patch Changes - fe592f88: Release - Updated dependencies [fe592f88] - @dusk-network/icon@4.6.9 - @dusk-network/helpers@4.6.9 - @dusk-network/button@4.6.9 - @dusk-network/menu@4.6.9 ## 4.6.8 ### Patch Changes - c33aa088: Release - Updated dependencies [c33aa088] - @dusk-network/icon@4.6.8 - @dusk-network/helpers@4.6.8 - @dusk-network/button@4.6.8 - @dusk-network/menu@4.6.8 ## 4.6.7 ### Patch Changes - 5afbc274: Release - Updated dependencies [5afbc274] - @dusk-network/icon@4.6.7 - @dusk-network/helpers@4.6.7 - @dusk-network/button@4.6.7 - @dusk-network/menu@4.6.7 ## 4.6.6 ### Patch Changes - a5caefeb: Release - Updated dependencies [a5caefeb] - @dusk-network/icon@4.6.6 - @dusk-network/helpers@4.6.6 - @dusk-network/button@4.6.6 - @dusk-network/menu@4.6.6 ## 4.6.5 ### Patch Changes - 10b60c57: Release - Updated dependencies [10b60c57] - @dusk-network/icon@4.6.5 - @dusk-network/helpers@4.6.5 - @dusk-network/button@4.6.5 - @dusk-network/menu@4.6.5 ## 4.6.4 ### Patch Changes - 8c74f26d: Release - Updated dependencies [8c74f26d] - @dusk-network/icon@4.6.4 - @dusk-network/helpers@4.6.4 - @dusk-network/button@4.6.4 - @dusk-network/menu@4.6.4 ## 4.6.3 ### Patch Changes - 0dafd544: Release - Updated dependencies [0dafd544] - @dusk-network/icon@4.6.3 - @dusk-network/helpers@4.6.3 - @dusk-network/button@4.6.3 - @dusk-network/menu@4.6.3 ## 4.6.2 ### Patch Changes - 182f1ea6: Release - Updated dependencies [182f1ea6] - @dusk-network/icon@4.6.2 - @dusk-network/helpers@4.6.2 - @dusk-network/button@4.6.2 - @dusk-network/menu@4.6.2 ## 4.6.1 ### Patch Changes - 88042090: Release - Updated dependencies [88042090] - @dusk-network/icon@4.6.1 - @dusk-network/helpers@4.6.1 - @dusk-network/button@4.6.1 - @dusk-network/menu@4.6.1 ## 4.6.0 ### Minor Changes - 9320f3b5: Release ### Patch Changes - Updated dependencies [9320f3b5] - @dusk-network/icon@4.6.0 - @dusk-network/helpers@4.6.0 - @dusk-network/button@4.6.0 - @dusk-network/menu@4.6.0 ## 4.5.6 ### Patch Changes - 80a609dd: Release - Updated dependencies [80a609dd] - @dusk-network/icon@4.5.6 - @dusk-network/helpers@4.5.6 - @dusk-network/button@4.5.6 - @dusk-network/menu@4.5.6 ## 4.5.5 ### Patch Changes - d326f7f0: Release - Updated dependencies [d326f7f0] - @dusk-network/icon@4.5.5 - @dusk-network/helpers@4.5.5 - @dusk-network/button@4.5.5 - @dusk-network/menu@4.5.5 ## 4.5.4 ### Patch Changes - bfca367b: Release - Updated dependencies [bfca367b] - @dusk-network/icon@4.5.4 - @dusk-network/helpers@4.5.4 - @dusk-network/button@4.5.4 - @dusk-network/menu@4.5.4 ## 4.5.3 ### Patch Changes - 55558e72: Release - Updated dependencies [55558e72] - @dusk-network/icon@4.5.3 - @dusk-network/helpers@4.5.3 - @dusk-network/button@4.5.3 - @dusk-network/menu@4.5.3 ## 4.5.2 ### Patch Changes - b252568f: Release - Updated dependencies [b252568f] - @dusk-network/icon@4.5.2 - @dusk-network/helpers@4.5.2 - @dusk-network/button@4.5.2 - @dusk-network/menu@4.5.2 ## 4.5.1 ### Patch Changes - bf08b6df: Release - Updated dependencies [bf08b6df] - @dusk-network/icon@4.5.1 - @dusk-network/helpers@4.5.1 - @dusk-network/button@4.5.1 - @dusk-network/menu@4.5.1 ## 4.5.0 ### Minor Changes - 023ecf0d: Release ### Patch Changes - Updated dependencies [023ecf0d] - @dusk-network/icon@4.5.0 - @dusk-network/helpers@4.5.0 - @dusk-network/button@4.5.0 - @dusk-network/menu@4.5.0 ## 4.4.0 ### Minor Changes - ca37e869: Release 4.3.0 ### Patch Changes - Updated dependencies [ca37e869] - @dusk-network/icon@4.4.0 - @dusk-network/helpers@4.4.0 - @dusk-network/button@4.4.0 - @dusk-network/menu@4.4.0 ## 4.3.1 ### Patch Changes - eeac67a4: Release 4.2.1 - Updated dependencies [eeac67a4] - @dusk-network/icon@4.3.1 - @dusk-network/helpers@4.3.1 - @dusk-network/button@4.3.1 - @dusk-network/menu@4.3.1 ## 4.3.0 ### Minor Changes - 7d390f05: Release 4.3.0 ### Patch Changes - Updated dependencies [7d390f05] - @dusk-network/icon@4.3.0 - @dusk-network/helpers@4.3.0 - @dusk-network/button@4.3.0 - @dusk-network/menu@4.3.0 ## 4.2.1 ### Patch Changes - b66edd71: Release 4.2.1 - Updated dependencies [b66edd71] - @dusk-network/icon@4.2.1 - @dusk-network/helpers@4.2.1 - @dusk-network/button@4.2.1 - @dusk-network/menu@4.2.1 ## 4.2.0 ### Minor Changes - 770e3502: Release 4.1.2 ### Patch Changes - Updated dependencies [770e3502] - @dusk-network/icon@4.2.0 - @dusk-network/helpers@4.2.0 - @dusk-network/button@4.2.0 - @dusk-network/menu@4.2.0 ## 4.1.1 ### Patch Changes - 03b53db4: Release 4.1.1 - Updated dependencies [03b53db4] - @dusk-network/icon@4.1.1 - @dusk-network/helpers@4.1.1 - @dusk-network/button@4.1.1 - @dusk-network/menu@4.1.1 ## 4.1.0 ### Minor Changes - b8dfbe58: Release 4.1.0 ### Patch Changes - Updated dependencies [b8dfbe58] - @dusk-network/icon@4.1.0 - @dusk-network/helpers@4.1.0 - @dusk-network/button@4.1.0 - @dusk-network/menu@4.1.0 ## 4.0.6 ### Patch Changes - 72ad415f: Release 4.0.6 - Updated dependencies [72ad415f] - @dusk-network/icon@4.0.6 - @dusk-network/helpers@4.0.6 - @dusk-network/button@4.0.6 - @dusk-network/menu@4.0.6 ## 4.0.5 ### Patch Changes - 2043c055: Release 4.0.4 - Updated dependencies [2043c055] - @dusk-network/icon@4.0.5 - @dusk-network/helpers@4.0.5 - @dusk-network/button@4.0.5 - @dusk-network/menu@4.0.5 ## 4.0.4 ### Patch Changes - 0f6d98e6: Release 4.0.4 - Updated dependencies [0f6d98e6] - @dusk-network/icon@4.0.4 - @dusk-network/helpers@4.0.4 - @dusk-network/button@4.0.4 - @dusk-network/menu@4.0.4 ## 4.0.3 ### Patch Changes - d0bfc346: Release v4.0.3 - Updated dependencies [d0bfc346] - @dusk-network/icon@4.0.3 - @dusk-network/helpers@4.0.3 - @dusk-network/button@4.0.3 - @dusk-network/menu@4.0.3 ## 4.0.2 ### Patch Changes - b7876f76: Releasing v4.0.2 - Updated dependencies [b7876f76] - @dusk-network/icon@4.0.2 - @dusk-network/helpers@4.0.2 - @dusk-network/button@4.0.2 - @dusk-network/menu@4.0.2 ## 4.0.1 ### Patch Changes - 3d02510e: Patch release for some boilerplate issues - Updated dependencies [3d02510e] - @dusk-network/icon@4.0.1 - @dusk-network/helpers@4.0.1 - @dusk-network/button@4.0.1 - @dusk-network/menu@4.0.1 ## 4.0.0 ### Major Changes - 11a1f850: Release V4 ### Minor Changes - a86c725b: Updating all packages to node modules format ### Patch Changes - Updated dependencies [11a1f850] - Updated dependencies [a86c725b] - @dusk-network/icon@4.0.0 - @dusk-network/helpers@4.0.0 - @dusk-network/button@4.0.0 - @dusk-network/menu@4.0.0 ## 3.0.12 ### Patch Changes - 66d1852b: Minor fixes for search-list component - Updated dependencies [66d1852b] - @dusk-network/icon@3.0.12 - @dusk-network/helpers@3.0.12 - @dusk-network/button@3.0.12 - @dusk-network/menu@3.0.12 ## 3.0.11 ### Patch Changes - e82126be: testing changesets - Updated dependencies [e82126be] - @dusk-network/icon@3.0.11 - @dusk-network/helpers@3.0.11 - @dusk-network/button@3.0.11 - @dusk-network/menu@3.0.11 ## 3.0.10 ### Patch Changes - 3bdf6fcd: testing changesets - Updated dependencies [3bdf6fcd] - @dusk-network/icon@3.0.10 - @dusk-network/helpers@3.0.10 - @dusk-network/button@3.0.10 - @dusk-network/menu@3.0.10 ## 3.0.9 ### Patch Changes - ddcc6129: testing changesets - Updated dependencies [ddcc6129] - @dusk-network/icon@3.0.9 - @dusk-network/helpers@3.0.9 - @dusk-network/button@3.0.9 - @dusk-network/menu@3.0.9 ## 3.0.8 ### Patch Changes - 59509914: testing changesets - 0258743d: testing changesets ci - Updated dependencies [59509914] - Updated dependencies [0258743d] - @dusk-network/icon@3.0.8 - @dusk-network/helpers@3.0.8 - @dusk-network/button@3.0.8 - @dusk-network/menu@3.0.8 ## 3.0.7 ### Patch Changes - 9fa40eb7: testing changesets - Updated dependencies [9fa40eb7] - @dusk-network/icon@3.0.7 - @dusk-network/helpers@3.0.7 - @dusk-network/button@3.0.7 - @dusk-network/menu@3.0.7 ## 3.0.6 ### Patch Changes - dc22a3aa: testing changesets - Updated dependencies [dc22a3aa] - @dusk-network/icon@3.0.6 - @dusk-network/helpers@3.0.6 - @dusk-network/button@3.0.6 - @dusk-network/menu@3.0.6 ## 3.0.5 ### Patch Changes - 006ffc63: testing changesets - Updated dependencies [006ffc63] - @dusk-network/icon@3.0.5 - @dusk-network/helpers@3.0.5 - @dusk-network/button@3.0.5 - @dusk-network/menu@3.0.5 ## 3.0.4 ### Patch Changes - 83b76ba8: testing changesets - Updated dependencies [83b76ba8] - @dusk-network/icon@3.0.4 - @dusk-network/helpers@3.0.4 - @dusk-network/button@3.0.4 - @dusk-network/menu@3.0.4 ## 3.0.3 ### Patch Changes - 365e4295: testing changesets - Updated dependencies [365e4295] - @dusk-network/icon@3.0.3 - @dusk-network/helpers@3.0.3 - @dusk-network/button@3.0.3 - @dusk-network/menu@3.0.3 ## 3.0.2 ### Patch Changes - d9360f5c: testing changesets - Updated dependencies [d9360f5c] - @dusk-network/icon@3.0.2 - @dusk-network/helpers@3.0.2 - @dusk-network/button@3.0.2 - @dusk-network/menu@3.0.2 ## 3.0.1 ### Patch Changes - ac84fdab: testing changesets - 33c8fedb: testing changesets - dd790adb: testing changesets - Updated dependencies [ac84fdab] - Updated dependencies [33c8fedb] - Updated dependencies [dd790adb] - @dusk-network/icon@3.0.1 - @dusk-network/helpers@3.0.1 - @dusk-network/button@3.0.1 - @dusk-network/menu@3.0.1 ## 0.0.1 ### Patch Changes - a10ea514: testing changesets - 2b3bda0b: testing changesets - 6d417df2: adding another changest - Updated dependencies [a10ea514] - Updated dependencies [2b3bda0b] - Updated dependencies [6d417df2] - @dusk-network/icon@0.0.1 - @dusk-network/helpers@0.0.1 - @dusk-network/button@0.0.1 - @dusk-network/menu@0.0.1
Markdown
MPL-2.0
dusk-network/dusk-ui-kit/packages/molecules/pagination/CHANGELOG.md
4446a1a8-e05e-4025-82cd-d8ffd7cc4349
[]
[]
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- namespace Think; /** * ThinkPHP 控制器基类 抽象类 */ abstract class Controller { public function get_data($tablename,$keyname,$key) { $obj=M($tablename); $data=$obj->where($keyname.'="'.$key.'"')->select(); return $data; } // 写入数据库 // $tablename表名称,字符串 // $data写入数据,字符串数组 // $redirectcontroller跳转的控制名,字符串 // $redirectpage跳转的页面,字符串 // $tips成功提示信息 public function write_db($tablename,$data,$redirectcontroller,$redirectpage,$tips) { $obj=M($tablename); $obj->data($data)->add(); if (!$obj->create($data)) { //验证没有通过 输出错误提示信息 $this->error($obj->getError()); exit(); }else{ $this->success($tips,U($redirectcontroller.'/'.$redirectpage)); } } // 按秒计算时间差,显示频繁使用AJAX POST public function postLimit() { if(isset($_SESSION['postTime'])){ $lastPostTime=session('postTime'); $now=date(YmdHis); $diff=strtotime($now)-strtotime(I('session.postTime')); session('postTime',date(YmdHis)); return $diff; }else{ session('postTime',date(YmdHis)); return 3; } } //用户权限校验 public function userauth() { session(null); redirect(U('Login/index')); } /** * 视图实例对象 * @var view * @access protected */ protected $view = null; /** * 控制器参数 * @var config * @access protected */ protected $config = array(); /** * 架构函数 取得模板对象实例 * @access public */ public function __construct() { Hook::listen('action_begin',$this->config); //实例化视图类 $this->view = Think::instance('Think\View'); //控制器初始化 if(method_exists($this,'_initialize')) $this->_initialize(); } /** * 模板显示 调用内置的模板引擎显示方法, * @access protected * @param string $templateFile 指定要调用的模板文件 * 默认为空 由系统自动定位模板文件 * @param string $charset 输出编码 * @param string $contentType 输出类型 * @param string $content 输出内容 * @param string $prefix 模板缓存前缀 * @return void */ protected function display($templateFile='',$charset='',$contentType='',$content='',$prefix='') { $this->view->display($templateFile,$charset,$contentType,$content,$prefix); } /** * 输出内容文本可以包括Html 并支持内容解析 * @access protected * @param string $content 输出内容 * @param string $charset 模板输出字符集 * @param string $contentType 输出类型 * @param string $prefix 模板缓存前缀 * @return mixed */ protected function show($content,$charset='',$contentType='',$prefix='') { $this->view->display('',$charset,$contentType,$content,$prefix); } /** * 获取输出页面内容 * 调用内置的模板引擎fetch方法, * @access protected * @param string $templateFile 指定要调用的模板文件 * 默认为空 由系统自动定位模板文件 * @param string $content 模板输出内容 * @param string $prefix 模板缓存前缀* * @return string */ protected function fetch($templateFile='',$content='',$prefix='') { return $this->view->fetch($templateFile,$content,$prefix); } /** * 创建静态页面 * @access protected * @htmlfile 生成的静态文件名称 * @htmlpath 生成的静态文件路径 * @param string $templateFile 指定要调用的模板文件 * 默认为空 由系统自动定位模板文件 * @return string */ protected function buildHtml($htmlfile='',$htmlpath='',$templateFile='') { $content = $this->fetch($templateFile); $htmlpath = !empty($htmlpath)?$htmlpath:HTML_PATH; $htmlfile = $htmlpath.$htmlfile.C('HTML_FILE_SUFFIX'); Storage::put($htmlfile,$content,'html'); return $content; } /** * 模板主题设置 * @access protected * @param string $theme 模版主题 * @return Action */ protected function theme($theme){ $this->view->theme($theme); return $this; } /** * 模板变量赋值 * @access protected * @param mixed $name 要显示的模板变量 * @param mixed $value 变量的值 * @return Action */ protected function assign($name,$value='') { $this->view->assign($name,$value); return $this; } public function __set($name,$value) { $this->assign($name,$value); } /** * 取得模板显示变量的值 * @access protected * @param string $name 模板显示变量 * @return mixed */ public function get($name='') { return $this->view->get($name); } public function __get($name) { return $this->get($name); } /** * 检测模板变量的值 * @access public * @param string $name 名称 * @return boolean */ public function __isset($name) { return $this->get($name); } /** * 魔术方法 有不存在的操作的时候执行 * @access public * @param string $method 方法名 * @param array $args 参数 * @return mixed */ public function __call($method,$args) { if( 0 === strcasecmp($method,ACTION_NAME.C('ACTION_SUFFIX'))) { if(method_exists($this,'_empty')) { // 如果定义了_empty操作 则调用 $this->_empty($method,$args); }elseif(file_exists_case($this->view->parseTemplate())){ // 检查是否存在默认模版 如果有直接输出模版 $this->display(); }else{ E(L('_ERROR_ACTION_').':'.ACTION_NAME); } }else{ E(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_')); return; } } /** * 操作错误跳转的快捷方法 * @access protected * @param string $message 错误信息 * @param string $jumpUrl 页面跳转地址 * @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间 * @return void */ protected function error($message='',$jumpUrl='',$ajax=false) { $this->dispatchJump($message,0,$jumpUrl,$ajax); } /** * 操作成功跳转的快捷方法 * @access protected * @param string $message 提示信息 * @param string $jumpUrl 页面跳转地址 * @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间 * @return void */ protected function success($message='',$jumpUrl='',$ajax=false) { $this->dispatchJump($message,1,$jumpUrl,$ajax); } /** * Ajax方式返回数据到客户端 * @access protected * @param mixed $data 要返回的数据 * @param String $type AJAX返回数据格式 * @param int $json_option 传递给json_encode的option参数 * @return void */ protected function ajaxReturn($data,$type='',$json_option=0) { if(empty($type)) $type = C('DEFAULT_AJAX_RETURN'); switch (strtoupper($type)){ case 'JSON' : // 返回JSON数据格式到客户端 包含状态信息 header('Content-Type:application/json; charset=utf-8'); exit(json_encode($data,$json_option)); case 'XML' : // 返回xml格式数据 header('Content-Type:text/xml; charset=utf-8'); exit(xml_encode($data)); case 'JSONP': // 返回JSON数据格式到客户端 包含状态信息 header('Content-Type:application/json; charset=utf-8'); $handler = isset($_GET[C('VAR_JSONP_HANDLER')]) ? $_GET[C('VAR_JSONP_HANDLER')] : C('DEFAULT_JSONP_HANDLER'); exit($handler.'('.json_encode($data,$json_option).');'); case 'EVAL' : // 返回可执行的js脚本 header('Content-Type:text/html; charset=utf-8'); exit($data); default : // 用于扩展其他返回格式数据 Hook::listen('ajax_return',$data); } } /** * Action跳转(URL重定向) 支持指定模块和延时跳转 * @access protected * @param string $url 跳转的URL表达式 * @param array $params 其它URL参数 * @param integer $delay 延时跳转的时间 单位为秒 * @param string $msg 跳转提示信息 * @return void */ protected function redirect($url,$params=array(),$delay=0,$msg='') { $url = U($url,$params); redirect($url,$delay,$msg); } /** * 默认跳转操作 支持错误导向和正确跳转 * 调用模板显示 默认为public目录下面的success页面 * 提示页面为可配置 支持模板标签 * @param string $message 提示信息 * @param Boolean $status 状态 * @param string $jumpUrl 页面跳转地址 * @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间 * @access private * @return void */ private function dispatchJump($message,$status=1,$jumpUrl='',$ajax=false) { if(true === $ajax || IS_AJAX) {// AJAX提交 $data = is_array($ajax)?$ajax:array(); $data['info'] = $message; $data['status'] = $status; $data['url'] = $jumpUrl; $this->ajaxReturn($data); } if(is_int($ajax)) $this->assign('waitSecond',$ajax); if(!empty($jumpUrl)) $this->assign('jumpUrl',$jumpUrl); // 提示标题 $this->assign('msgTitle',$status? L('_OPERATION_SUCCESS_') : L('_OPERATION_FAIL_')); //如果设置了关闭窗口,则提示完毕后自动关闭窗口 if($this->get('closeWin')) $this->assign('jumpUrl','javascript:window.close();'); $this->assign('status',$status); // 状态 //保证输出不受静态缓存影响 C('HTML_CACHE_ON',false); if($status) { //发送成功信息 $this->assign('message',$message);// 提示信息 // 成功操作后默认停留1秒 if(!isset($this->waitSecond)) $this->assign('waitSecond','3'); // 默认操作成功自动返回操作前页面 if(!isset($this->jumpUrl)) $this->assign("jumpUrl",$_SERVER["HTTP_REFERER"]); $this->display(C('TMPL_ACTION_SUCCESS')); }else{ $this->assign('error',$message);// 提示信息 //发生错误时候默认停留3秒 if(!isset($this->waitSecond)) $this->assign('waitSecond','3'); // 默认发生错误的话自动返回上页 if(!isset($this->jumpUrl)) $this->assign('jumpUrl',"javascript:history.back(-1);"); $this->display(C('TMPL_ACTION_ERROR')); // 中止执行 避免出错后继续执行 exit ; } } /** * 析构方法 * @access public */ public function __destruct() { // 执行后续操作 Hook::listen('action_end'); } } // 设置控制器别名 便于升级 class_alias('Think\Controller','Think\Action');
PHP
Apache-2.0
roinheart/insurance/ThinkPHP/Library/Think/Controller.class.php
7aecfd34-1698-4cb3-8f3e-ddb86d9ec227
[{"tag": "USERNAME", "value": "liu21st", "start": 494, "end": 501, "context": "------------------------------------\n// | Author: liu21st <liu21st@gmail.com>\n// +-------------------------"}, {"tag": "EMAIL", "value": "liu21st@gmail.com", "start": 503, "end": 520, "context": "---------------------------\n// | Author: liu21st <liu21st@gmail.com>\n// +--------------------------------------------"}]
[{"tag": "USERNAME", "value": "liu21st", "start": 494, "end": 501, "context": "------------------------------------\n// | Author: liu21st <liu21st@gmail.com>\n// +-------------------------"}, {"tag": "EMAIL", "value": "liu21st@gmail.com", "start": 503, "end": 520, "context": "---------------------------\n// | Author: liu21st <liu21st@gmail.com>\n// +--------------------------------------------"}]
var annotated_dup = [ [ "Zeebe", "d6/d18/namespaceZeebe.html", [ [ "Client", "da/d88/namespaceZeebe_1_1Client.html", [ [ "Api", "d5/df7/namespaceZeebe_1_1Client_1_1Api.html", [ [ "Builder", "dc/d04/namespaceZeebe_1_1Client_1_1Api_1_1Builder.html", [ [ "IAccessTokenSupplier", "d2/d24/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IAccessTokenSupplier.html", null ], [ "ICamundaCloudClientBuilder", "d7/d02/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudClientBuilder.html", "d7/d02/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudClientBuilder" ], [ "ICamundaCloudClientBuilderStep1", "d7/d12/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudClientBuilderStep1.html", "d7/d12/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudClientBuilderStep1" ], [ "ICamundaCloudClientBuilderStep2", "d9/d8a/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudClientBuilderStep2.html", "d9/d8a/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudClientBuilderStep2" ], [ "ICamundaCloudClientBuilderFinalStep", "d1/d61/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudClientBuilderFinalStep.html", "d1/d61/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudClientBuilderFinalStep" ], [ "ICamundaCloudTokenProviderBuilder", "d3/d08/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilder.html", "d3/d08/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilder" ], [ "ICamundaCloudTokenProviderBuilderStep2", "de/db1/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilderStep2.html", "de/db1/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilderStep2" ], [ "ICamundaCloudTokenProviderBuilderStep3", "d8/d4e/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilderStep3.html", "d8/d4e/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilderStep3" ], [ "ICamundaCloudTokenProviderBuilderStep4", "da/d5d/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilderStep4.html", "da/d5d/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilderStep4" ], [ "ICamundaCloudTokenProviderBuilderFinalStep", "d6/dd9/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilderFinalStep.html", "d6/dd9/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1ICamundaCloudTokenProviderBuilderFinalStep" ], [ "IZeebeClientBuilder", "d2/d7d/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IZeebeClientBuilder.html", "d2/d7d/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IZeebeClientBuilder" ], [ "IZeebeClientTransportBuilder", "d2/df5/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IZeebeClientTransportBuilder.html", "d2/df5/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IZeebeClientTransportBuilder" ], [ "IZeebeSecureClientBuilder", "d6/d64/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IZeebeSecureClientBuilder.html", "d6/d64/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IZeebeSecureClientBuilder" ], [ "IZeebeClientFinalBuildStep", "d6/d2b/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IZeebeClientFinalBuildStep.html", "d6/d2b/interfaceZeebe_1_1Client_1_1Api_1_1Builder_1_1IZeebeClientFinalBuildStep" ] ] ], [ "Commands", "d9/def/namespaceZeebe_1_1Client_1_1Api_1_1Commands.html", [ [ "IActivateJobsCommandStep1", "d4/d1d/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IActivateJobsCommandStep1.html", "d4/d1d/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IActivateJobsCommandStep1" ], [ "IActivateJobsCommandStep2", "d0/d9e/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IActivateJobsCommandStep2.html", "d0/d9e/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IActivateJobsCommandStep2" ], [ "IActivateJobsCommandStep3", "df/d94/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IActivateJobsCommandStep3.html", "df/d94/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IActivateJobsCommandStep3" ], [ "ICancelProcessInstanceCommandStep1", "d5/d79/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICancelProcessInstanceCommandStep1.html", null ], [ "ICompleteJobCommandStep1", "d2/d53/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICompleteJobCommandStep1.html", "d2/d53/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICompleteJobCommandStep1" ], [ "ICreateProcessInstanceCommandStep1", "dc/db3/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICreateProcessInstanceCommandStep1.html", "dc/db3/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICreateProcessInstanceCommandStep1" ], [ "ICreateProcessInstanceCommandStep2", "df/d4a/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICreateProcessInstanceCommandStep2.html", "df/d4a/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICreateProcessInstanceCommandStep2" ], [ "ICreateProcessInstanceCommandStep3", "d0/db3/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICreateProcessInstanceCommandStep3.html", "d0/db3/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICreateProcessInstanceCommandStep3" ], [ "ICreateProcessInstanceWithResultCommandStep1", "dd/dd6/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICreateProcessInstanceWithResultCommandStep1.html", "dd/dd6/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ICreateProcessInstanceWithResultCommandStep1" ], [ "IDeployProcessCommandStep1", "d6/db0/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IDeployProcessCommandStep1.html", "d6/db0/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IDeployProcessCommandStep1" ], [ "IDeployProcessCommandBuilderStep2", "da/d46/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IDeployProcessCommandBuilderStep2.html", null ], [ "IFailJobCommandStep1", "d9/de4/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IFailJobCommandStep1.html", "d9/de4/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IFailJobCommandStep1" ], [ "IFailJobCommandStep2", "d5/d66/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IFailJobCommandStep2.html", "d5/d66/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IFailJobCommandStep2" ], [ "IFinalCommandStep", "d2/de4/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IFinalCommandStep.html", "d2/de4/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IFinalCommandStep" ], [ "IFinalCommandWithRetryStep", "d5/d5e/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IFinalCommandWithRetryStep.html", "d5/d5e/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IFinalCommandWithRetryStep" ], [ "IPublishMessageCommandStep1", "d8/d8d/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IPublishMessageCommandStep1.html", "d8/d8d/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IPublishMessageCommandStep1" ], [ "IPublishMessageCommandStep2", "d9/d49/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IPublishMessageCommandStep2.html", "d9/d49/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IPublishMessageCommandStep2" ], [ "IPublishMessageCommandStep3", "d5/d02/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IPublishMessageCommandStep3.html", "d5/d02/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IPublishMessageCommandStep3" ], [ "IResolveIncidentCommandStep1", "d0/d39/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IResolveIncidentCommandStep1.html", null ], [ "ISetVariablesCommandStep1", "d2/d5d/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ISetVariablesCommandStep1.html", "d2/d5d/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ISetVariablesCommandStep1" ], [ "ISetVariablesCommandStep2", "de/de4/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ISetVariablesCommandStep2.html", "de/de4/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ISetVariablesCommandStep2" ], [ "IThrowErrorCommandStep1", "d4/d22/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IThrowErrorCommandStep1.html", "d4/d22/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IThrowErrorCommandStep1" ], [ "IThrowErrorCommandStep2", "d3/d85/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IThrowErrorCommandStep2.html", "d3/d85/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IThrowErrorCommandStep2" ], [ "ITopologyRequestStep1", "d5/dae/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1ITopologyRequestStep1.html", null ], [ "IUpdateRetriesCommandStep1", "da/d9d/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IUpdateRetriesCommandStep1.html", "da/d9d/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IUpdateRetriesCommandStep1" ], [ "IUpdateRetriesCommandStep2", "dd/dec/interfaceZeebe_1_1Client_1_1Api_1_1Commands_1_1IUpdateRetriesCommandStep2.html", null ] ] ], [ "Misc", "de/df7/namespaceZeebe_1_1Client_1_1Api_1_1Misc.html", [ [ "IAsyncRetryStrategy", "de/d82/interfaceZeebe_1_1Client_1_1Api_1_1Misc_1_1IAsyncRetryStrategy.html", "de/d82/interfaceZeebe_1_1Client_1_1Api_1_1Misc_1_1IAsyncRetryStrategy" ] ] ], [ "Responses", "dd/db3/namespaceZeebe_1_1Client_1_1Api_1_1Responses.html", [ [ "IActivateJobsResponse", "d5/d31/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IActivateJobsResponse.html", "d5/d31/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IActivateJobsResponse" ], [ "IBrokerInfo", "d7/dce/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IBrokerInfo.html", "d7/dce/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IBrokerInfo" ], [ "ICancelProcessInstanceResponse", "d9/d27/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1ICancelProcessInstanceResponse.html", null ], [ "ICompleteJobResponse", "d3/d3e/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1ICompleteJobResponse.html", null ], [ "IDeployResponse", "de/d05/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IDeployResponse.html", "de/d05/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IDeployResponse" ], [ "IFailJobResponse", "de/d8a/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IFailJobResponse.html", null ], [ "IJob", "dc/ddb/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IJob.html", "dc/ddb/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IJob" ], [ "IPartitionInfo", "d7/d34/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IPartitionInfo.html", "d7/d34/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IPartitionInfo" ], [ "IProcessInstanceResponse", "dd/d46/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IProcessInstanceResponse.html", "dd/d46/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IProcessInstanceResponse" ], [ "IProcessInstanceResult", "d0/dd0/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IProcessInstanceResult.html", "d0/dd0/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IProcessInstanceResult" ], [ "IProcessMetadata", "db/df6/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IProcessMetadata.html", "db/df6/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IProcessMetadata" ], [ "IPublishMessageResponse", "d0/dab/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IPublishMessageResponse.html", null ], [ "IResolveIncidentResponse", "de/df8/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IResolveIncidentResponse.html", null ], [ "ISetVariablesResponse", "d7/d1a/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1ISetVariablesResponse.html", "d7/d1a/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1ISetVariablesResponse" ], [ "IThrowErrorResponse", "d7/d26/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IThrowErrorResponse.html", null ], [ "ITopology", "df/d68/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1ITopology.html", "df/d68/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1ITopology" ], [ "IUpdateRetriesResponse", "d7/df3/interfaceZeebe_1_1Client_1_1Api_1_1Responses_1_1IUpdateRetriesResponse.html", null ] ] ], [ "Worker", "db/d2d/namespaceZeebe_1_1Client_1_1Api_1_1Worker.html", [ [ "IJobClient", "df/d67/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobClient.html", "df/d67/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobClient" ], [ "IJobWorker", "d1/dfe/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobWorker.html", "d1/dfe/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobWorker" ], [ "IJobWorkerBuilderStep1", "d5/dc7/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobWorkerBuilderStep1.html", "d5/dc7/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobWorkerBuilderStep1" ], [ "IJobWorkerBuilderStep2", "d5/d42/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobWorkerBuilderStep2.html", "d5/d42/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobWorkerBuilderStep2" ], [ "IJobWorkerBuilderStep3", "d2/d59/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobWorkerBuilderStep3.html", "d2/d59/interfaceZeebe_1_1Client_1_1Api_1_1Worker_1_1IJobWorkerBuilderStep3" ] ] ] ] ], [ "IZeebeClient", "d7/dd6/interfaceZeebe_1_1Client_1_1IZeebeClient.html", "d7/dd6/interfaceZeebe_1_1Client_1_1IZeebeClient" ] ] ] ] ] ];
JavaScript
Apache-2.0
Christian-Oleson/zeebe-client-csharp/docs/annotated_dup.js
ca6e0b8c-9f14-405b-bf82-fdb45115d830
[]
[]
/**************************************************************************** * * Copyright (c) 2013-2016 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name PX4 nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ /** * @file vmount.cpp * @author Leon Müller (thedevleon) * @author Beat Küng <beat-kueng@gmx.net> * MAV_MOUNT driver for controlling mavlink gimbals, rc gimbals/servors and * future kinds of mounts. * */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <systemlib/err.h> #include <px4_defines.h> #include <px4_tasks.h> #include "input_mavlink.h" #include "input_rc.h" #include "input_test.h" #include "output_rc.h" #include "output_mavlink.h" #include <uORB/uORB.h> #include <uORB/topics/parameter_update.h> #include <px4_config.h> using namespace vmount; /* thread state */ static volatile bool thread_should_exit = false; static volatile bool thread_running = false; struct ThreadData { InputBase *input_obj = nullptr; OutputBase *output_obj = nullptr; }; static volatile ThreadData *g_thread_data = nullptr; struct Parameters { int mnt_mode_in; int mnt_mode_out; int mnt_mav_sysid; int mnt_mav_compid; int mnt_ob_lock_mode; int mnt_ob_norm_mode; int mnt_man_control; int mnt_man_pitch; int mnt_man_roll; int mnt_man_yaw; bool operator!=(const Parameters &p) { return mnt_mode_in != p.mnt_mode_in || mnt_mode_out != p.mnt_mode_out || mnt_mav_sysid != p.mnt_mav_sysid || mnt_mav_compid != p.mnt_mav_compid || mnt_ob_lock_mode != p.mnt_ob_lock_mode || mnt_ob_norm_mode != p.mnt_ob_norm_mode || mnt_man_control != p.mnt_man_control || mnt_man_pitch != p.mnt_man_pitch || mnt_man_roll != p.mnt_man_roll || mnt_man_yaw != p.mnt_man_yaw; } }; struct ParameterHandles { param_t mnt_mode_in; param_t mnt_mode_out; param_t mnt_mav_sysid; param_t mnt_mav_compid; param_t mnt_ob_lock_mode; param_t mnt_ob_norm_mode; param_t mnt_man_control; param_t mnt_man_pitch; param_t mnt_man_roll; param_t mnt_man_yaw; }; /* functions */ static void usage(void); static void update_params(ParameterHandles &param_handles, Parameters &params, bool &got_changes); static bool get_params(ParameterHandles &param_handles, Parameters &params); static int vmount_thread_main(int argc, char *argv[]); extern "C" __EXPORT int vmount_main(int argc, char *argv[]); static void usage() { PX4_INFO("usage: vmount {start|stop|status|test}"); PX4_INFO(" vmount test {roll|pitch|yaw} <angle_deg>"); } static int vmount_thread_main(int argc, char *argv[]) { ParameterHandles param_handles; Parameters params; OutputConfig output_config; ThreadData thread_data; memset(&params, 0, sizeof(params)); InputTest *test_input = nullptr; #ifdef __PX4_NUTTX /* the NuttX optarg handler does not * ignore argv[0] like the POSIX handler * does, nor does it deal with non-flag * verbs well. So we Remove the application * name and the verb. */ argc -= 1; argv += 1; #endif if (argc > 0 && !strcmp(argv[0], "test")) { PX4_INFO("Starting in test mode"); const char *axis_names[3] = {"roll", "pitch", "yaw"}; float angles[3] = { 0.f, 0.f, 0.f }; if (argc == 3) { bool found_axis = false; for (int i = 0 ; i < 3; ++i) { if (!strcmp(argv[1], axis_names[i])) { long angle_deg = strtol(argv[2], NULL, 0); angles[i] = (float)angle_deg; found_axis = true; } } if (!found_axis) { usage(); return -1; } test_input = new InputTest(angles[0], angles[1], angles[2]); if (!test_input) { PX4_ERR("memory allocation failed"); return -1; } } else { usage(); return -1; } } if (!get_params(param_handles, params)) { PX4_ERR("could not get mount parameters!"); return -1; } int parameter_update_sub = orb_subscribe(ORB_ID(parameter_update)); thread_running = true; ControlData *control_data = nullptr; InputRC *manual_input = nullptr; g_thread_data = &thread_data; while (!thread_should_exit) { if (!thread_data.input_obj && (params.mnt_mode_in != 0 || test_input)) { //need to initialize output_config.gimbal_normal_mode_value = params.mnt_ob_norm_mode; output_config.gimbal_retracted_mode_value = params.mnt_ob_lock_mode; output_config.mavlink_sys_id = params.mnt_mav_sysid; output_config.mavlink_comp_id = params.mnt_mav_compid; if (test_input) { thread_data.input_obj = test_input; } else { if (params.mnt_man_control) { manual_input = new InputRC(params.mnt_man_roll, params.mnt_man_pitch, params.mnt_man_yaw); if (!manual_input) { PX4_ERR("memory allocation failed"); break; } } switch (params.mnt_mode_in) { case 1: //RC if (manual_input) { thread_data.input_obj = manual_input; manual_input = nullptr; } else { thread_data.input_obj = new InputRC(params.mnt_man_roll, params.mnt_man_pitch, params.mnt_man_yaw); } break; case 2: //MAVLINK_ROI thread_data.input_obj = new InputMavlinkROI(manual_input); break; case 3: //MAVLINK_DO_MOUNT thread_data.input_obj = new InputMavlinkCmdMount(manual_input); break; default: PX4_ERR("invalid input mode %i", params.mnt_mode_in); break; } } switch (params.mnt_mode_out) { case 0: //AUX thread_data.output_obj = new OutputRC(output_config); break; case 1: //MAVLINK thread_data.output_obj = new OutputMavlink(output_config); break; default: PX4_ERR("invalid output mode %i", params.mnt_mode_out); break; } if (!thread_data.input_obj || !thread_data.output_obj) { PX4_ERR("memory allocation failed"); thread_should_exit = true; break; } int ret = thread_data.output_obj->initialize(); if (ret) { PX4_ERR("failed to initialize output mode (%i)", ret); thread_should_exit = true; break; } } if (thread_data.input_obj) { //get input: we cannot make the timeout too large, because the output needs to update //periodically for stabilization and angle updates. int ret = thread_data.input_obj->update(50, &control_data); if (ret) { PX4_ERR("failed to read input (%i)", ret); break; } //update output ret = thread_data.output_obj->update(control_data); if (ret) { PX4_ERR("failed to write output (%i)", ret); break; } thread_data.output_obj->publish(); } else { //wait for parameter changes. We still need to wake up regularily to check for thread exit requests usleep(1e6); } if (test_input && test_input->finished()) { thread_should_exit = true; break; } //check for parameter changes bool updated; if (orb_check(parameter_update_sub, &updated) == 0 && updated) { parameter_update_s param_update; orb_copy(ORB_ID(parameter_update), parameter_update_sub, &param_update); update_params(param_handles, params, updated); if (updated) { //re-init objects if (thread_data.input_obj) { delete(thread_data.input_obj); thread_data.input_obj = nullptr; } if (thread_data.output_obj) { delete(thread_data.output_obj); thread_data.output_obj = nullptr; } if (manual_input) { delete(manual_input); manual_input = nullptr; } } } } g_thread_data = nullptr; orb_unsubscribe(parameter_update_sub); if (thread_data.input_obj) { delete(thread_data.input_obj); thread_data.input_obj = nullptr; } if (thread_data.output_obj) { delete(thread_data.output_obj); thread_data.output_obj = nullptr; } if (manual_input) { delete(manual_input); manual_input = nullptr; } thread_running = false; return 0; } /** * The main command function. * Processes command line arguments and starts the daemon. */ int vmount_main(int argc, char *argv[]) { if (argc < 2) { PX4_ERR("missing command"); usage(); return -1; } if (!strcmp(argv[1], "start") || !strcmp(argv[1], "test")) { /* this is not an error */ if (thread_running) { PX4_WARN("mount driver already running"); return 0; } thread_should_exit = false; int vmount_task = px4_task_spawn_cmd("vmount", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT + 40, 1500, vmount_thread_main, (char *const *)argv + 1); int counter = 0; while (!thread_running && vmount_task >= 0) { usleep(5000); if (++counter >= 100) { break; } } if (vmount_task < 0) { PX4_ERR("failed to start"); return -1; } return counter < 100 || thread_should_exit ? 0 : -1; } if (!strcmp(argv[1], "stop")) { /* this is not an error */ if (!thread_running) { PX4_WARN("mount driver not running"); return 0; } thread_should_exit = true; while (thread_running) { usleep(100000); } return 0; } if (!strcmp(argv[1], "status")) { if (thread_running && g_thread_data) { if (g_thread_data->input_obj) { g_thread_data->input_obj->print_status(); } else { PX4_INFO("Input: None"); } if (g_thread_data->output_obj) { g_thread_data->output_obj->print_status(); } else { PX4_INFO("Output: None"); } } else { PX4_INFO("not running"); } return 0; } PX4_ERR("unrecognized command"); usage(); return -1; } void update_params(ParameterHandles &param_handles, Parameters &params, bool &got_changes) { Parameters prev_params = params; param_get(param_handles.mnt_mode_in, &params.mnt_mode_in); param_get(param_handles.mnt_mode_out, &params.mnt_mode_out); param_get(param_handles.mnt_mav_sysid, &params.mnt_mav_sysid); param_get(param_handles.mnt_mav_compid, &params.mnt_mav_compid); param_get(param_handles.mnt_ob_lock_mode, &params.mnt_ob_lock_mode); param_get(param_handles.mnt_ob_norm_mode, &params.mnt_ob_norm_mode); param_get(param_handles.mnt_man_control, &params.mnt_man_control); param_get(param_handles.mnt_man_pitch, &params.mnt_man_pitch); param_get(param_handles.mnt_man_roll, &params.mnt_man_roll); param_get(param_handles.mnt_man_yaw, &params.mnt_man_yaw); got_changes = prev_params != params; } bool get_params(ParameterHandles &param_handles, Parameters &params) { param_handles.mnt_mode_in = param_find("MNT_MODE_IN"); param_handles.mnt_mode_out = param_find("MNT_MODE_OUT"); param_handles.mnt_mav_sysid = param_find("MNT_MAV_SYSID"); param_handles.mnt_mav_compid = param_find("MNT_MAV_COMPID"); param_handles.mnt_ob_lock_mode = param_find("MNT_OB_LOCK_MODE"); param_handles.mnt_ob_norm_mode = param_find("MNT_OB_NORM_MODE"); param_handles.mnt_man_control = param_find("MNT_MAN_CONTROL"); param_handles.mnt_man_pitch = param_find("MNT_MAN_PITCH"); param_handles.mnt_man_roll = param_find("MNT_MAN_ROLL"); param_handles.mnt_man_yaw = param_find("MNT_MAN_YAW"); if (param_handles.mnt_mode_in == PARAM_INVALID || param_handles.mnt_mode_out == PARAM_INVALID || param_handles.mnt_mav_sysid == PARAM_INVALID || param_handles.mnt_mav_compid == PARAM_INVALID || param_handles.mnt_ob_lock_mode == PARAM_INVALID || param_handles.mnt_ob_norm_mode == PARAM_INVALID || param_handles.mnt_man_control == PARAM_INVALID || param_handles.mnt_man_pitch == PARAM_INVALID || param_handles.mnt_man_roll == PARAM_INVALID || param_handles.mnt_man_yaw == PARAM_INVALID) { return false; } bool dummy; update_params(param_handles, params, dummy); return true; }
C++
BSD-3-Clause
mazahner/Firmware/src/drivers/vmount/vmount.cpp
47901599-8de3-4aa6-8835-9665fcc115f3
[{"tag": "EMAIL", "value": "beat-kueng@gmx.net", "start": 1820, "end": 1838, "context": "or Leon M\u00fcller (thedevleon)\n * @author Beat K\u00fcng <beat-kueng@gmx.net>\n * MAV_MOUNT driver for controlling mavlink gimb"}, {"tag": "USERNAME", "value": "thedevleon", "start": 1786, "end": 1796, "context": "\n\n/**\n * @file vmount.cpp\n * @author Leon M\u00fcller (thedevleon)\n * @author Beat K\u00fcng <beat-kueng@gmx.net>\n * MAV"}, {"tag": "NAME", "value": "Beat K\u00fcng", "start": 1809, "end": 1818, "context": "pp\n * @author Leon M\u00fcller (thedevleon)\n * @author Beat K\u00fcng <beat-kueng@gmx.net>\n * MAV_MOUNT driver for cont"}, {"tag": "NAME", "value": "Leon M\u00fcller", "start": 1773, "end": 1784, "context": "************/\n\n/**\n * @file vmount.cpp\n * @author Leon M\u00fcller (thedevleon)\n * @author Beat K\u00fcng <beat-kueng@gmx"}]
[{"tag": "EMAIL", "value": "beat-kueng@gmx.net", "start": 1820, "end": 1838, "context": "or Leon M\u00fcller (thedevleon)\n * @author Beat K\u00fcng <beat-kueng@gmx.net>\n * MAV_MOUNT driver for controlling mavlink gimb"}, {"tag": "USERNAME", "value": "thedevleon", "start": 1786, "end": 1796, "context": "\n\n/**\n * @file vmount.cpp\n * @author Leon M\u00fcller (thedevleon)\n * @author Beat K\u00fcng <beat-kueng@gmx.net>\n * MAV"}, {"tag": "NAME", "value": "Beat K\u00fcng", "start": 1809, "end": 1818, "context": "pp\n * @author Leon M\u00fcller (thedevleon)\n * @author Beat K\u00fcng <beat-kueng@gmx.net>\n * MAV_MOUNT driver for cont"}, {"tag": "NAME", "value": "Leon M\u00fcller", "start": 1773, "end": 1784, "context": "************/\n\n/**\n * @file vmount.cpp\n * @author Leon M\u00fcller (thedevleon)\n * @author Beat K\u00fcng <beat-kueng@gmx"}]
/* Copyright 2012 Aphid Mobile Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* * Copyright (C) 1999-2002 Harri Porten (porten@kde.org) * Copyright (C) 2001 Peter Kelly (pmk@post.com) * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) * Copyright (C) 2007 Maks Orlovich * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #include "config.h" #include "AJGlobalObjectFunctions.h" #include "CallFrame.h" #include "GlobalEvalFunction.h" #include "Interpreter.h" #include "AJGlobalObject.h" #include "AJString.h" #include "AJStringBuilder.h" #include "Lexer.h" #include "LiteralParser.h" #include "Nodes.h" #include "Parser.h" #include "StringBuilder.h" #include "StringExtras.h" #include "dtoa.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <wtf/ASCIICType.h> #include <wtf/Assertions.h> #include <wtf/MathExtras.h> #include <wtf/unicode/UTF8.h> using namespace ATF; using namespace Unicode; namespace AJ { static AJValue encode(ExecState* exec, const ArgList& args, const char* doNotEscape) { UString str = args.at(0).toString(exec); CString cstr = str.UTF8String(true); if (!cstr.data()) return throwError(exec, URIError, "String contained an illegal UTF-16 sequence."); AJStringBuilder builder; const char* p = cstr.data(); for (size_t k = 0; k < cstr.length(); k++, p++) { char c = *p; if (c && strchr(doNotEscape, c)) builder.append(c); else { char tmp[4]; snprintf(tmp, sizeof(tmp), "%%%02X", static_cast<unsigned char>(c)); builder.append(tmp); } } return builder.build(exec); } static AJValue decode(ExecState* exec, const ArgList& args, const char* doNotUnescape, bool strict) { AJStringBuilder builder; UString str = args.at(0).toString(exec); int k = 0; int len = str.size(); const UChar* d = str.data(); UChar u = 0; while (k < len) { const UChar* p = d + k; UChar c = *p; if (c == '%') { int charLen = 0; if (k <= len - 3 && isASCIIHexDigit(p[1]) && isASCIIHexDigit(p[2])) { const char b0 = Lexer::convertHex(p[1], p[2]); const int sequenceLen = UTF8SequenceLength(b0); if (sequenceLen != 0 && k <= len - sequenceLen * 3) { charLen = sequenceLen * 3; char sequence[5]; sequence[0] = b0; for (int i = 1; i < sequenceLen; ++i) { const UChar* q = p + i * 3; if (q[0] == '%' && isASCIIHexDigit(q[1]) && isASCIIHexDigit(q[2])) sequence[i] = Lexer::convertHex(q[1], q[2]); else { charLen = 0; break; } } if (charLen != 0) { sequence[sequenceLen] = 0; const int character = decodeUTF8Sequence(sequence); if (character < 0 || character >= 0x110000) charLen = 0; else if (character >= 0x10000) { // Convert to surrogate pair. builder.append(static_cast<UChar>(0xD800 | ((character - 0x10000) >> 10))); u = static_cast<UChar>(0xDC00 | ((character - 0x10000) & 0x3FF)); } else u = static_cast<UChar>(character); } } } if (charLen == 0) { if (strict) return throwError(exec, URIError); // The only case where we don't use "strict" mode is the "unescape" function. // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE. if (k <= len - 6 && p[1] == 'u' && isASCIIHexDigit(p[2]) && isASCIIHexDigit(p[3]) && isASCIIHexDigit(p[4]) && isASCIIHexDigit(p[5])) { charLen = 6; u = Lexer::convertUnicode(p[2], p[3], p[4], p[5]); } } if (charLen && (u == 0 || u >= 128 || !strchr(doNotUnescape, u))) { c = u; k += charLen - 1; } } k++; builder.append(c); } return builder.build(exec); } bool isStrWhiteSpace(UChar c) { switch (c) { case 0x0009: case 0x000A: case 0x000B: case 0x000C: case 0x000D: case 0x0020: case 0x00A0: case 0x2028: case 0x2029: return true; default: return c > 0xff && isSeparatorSpace(c); } } static int parseDigit(unsigned short c, int radix) { int digit = -1; if (c >= '0' && c <= '9') digit = c - '0'; else if (c >= 'A' && c <= 'Z') digit = c - 'A' + 10; else if (c >= 'a' && c <= 'z') digit = c - 'a' + 10; if (digit >= radix) return -1; return digit; } double parseIntOverflow(const char* s, int length, int radix) { double number = 0.0; double radixMultiplier = 1.0; for (const char* p = s + length - 1; p >= s; p--) { if (radixMultiplier == Inf) { if (*p != '0') { number = Inf; break; } } else { int digit = parseDigit(*p, radix); number += digit * radixMultiplier; } radixMultiplier *= radix; } return number; } static double parseInt(const UString& s, int radix) { int length = s.size(); const UChar* data = s.data(); int p = 0; while (p < length && isStrWhiteSpace(data[p])) ++p; double sign = 1; if (p < length) { if (data[p] == '+') ++p; else if (data[p] == '-') { sign = -1; ++p; } } if ((radix == 0 || radix == 16) && length - p >= 2 && data[p] == '0' && (data[p + 1] == 'x' || data[p + 1] == 'X')) { radix = 16; p += 2; } else if (radix == 0) { if (p < length && data[p] == '0') radix = 8; else radix = 10; } if (radix < 2 || radix > 36) return NaN; int firstDigitPosition = p; bool sawDigit = false; double number = 0; while (p < length) { int digit = parseDigit(data[p], radix); if (digit == -1) break; sawDigit = true; number *= radix; number += digit; ++p; } if (number >= mantissaOverflowLowerBound) { // FIXME: It is incorrect to use UString::ascii() here because it's not thread-safe. if (radix == 10) number = ATF::strtod(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), 0); else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32) number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), p - firstDigitPosition, radix); } if (!sawDigit) return NaN; return sign * number; } static double parseFloat(const UString& s) { // Check for 0x prefix here, because toDouble allows it, but we must treat it as 0. // Need to skip any whitespace and then one + or - sign. int length = s.size(); const UChar* data = s.data(); int p = 0; while (p < length && isStrWhiteSpace(data[p])) ++p; if (p < length && (data[p] == '+' || data[p] == '-')) ++p; if (length - p >= 2 && data[p] == '0' && (data[p + 1] == 'x' || data[p + 1] == 'X')) return 0; // FIXME: UString::toDouble will ignore leading ASCII spaces, but we need to ignore // other StrWhiteSpaceChar values as well. return s.toDouble(true /*tolerant*/, false /* NaN for empty string */); } AJValue JSC_HOST_CALL globalFuncEval(ExecState* exec, AJObject* function, AJValue thisValue, const ArgList& args) { AJObject* thisObject = thisValue.toThisObject(exec); AJObject* unwrappedObject = thisObject->unwrappedObject(); if (!unwrappedObject->isGlobalObject() || static_cast<AJGlobalObject*>(unwrappedObject)->evalFunction() != function) return throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated"); AJValue x = args.at(0); if (!x.isString()) return x; UString s = x.toString(exec); LiteralParser preparser(exec, s, LiteralParser::NonStrictJSON); if (AJValue parsedObject = preparser.tryLiteralParse()) return parsedObject; RefPtr<EvalExecutable> eval = EvalExecutable::create(exec, makeSource(s)); AJObject* error = eval->compile(exec, static_cast<AJGlobalObject*>(unwrappedObject)->globalScopeChain().node()); if (error) return throwError(exec, error); return exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<AJGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot()); } AJValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec, AJObject*, AJValue, const ArgList& args) { AJValue value = args.at(0); int32_t radix = args.at(1).toInt32(exec); if (radix != 0 && radix != 10) return jsNumber(exec, parseInt(value.toString(exec), radix)); if (value.isInt32()) return value; if (value.isDouble()) { double d = value.asDouble(); if (isfinite(d)) return jsNumber(exec, (d > 0) ? floor(d) : ceil(d)); if (isnan(d) || isinf(d)) return jsNaN(exec); return jsNumber(exec, 0); } return jsNumber(exec, parseInt(value.toString(exec), radix)); } AJValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec, AJObject*, AJValue, const ArgList& args) { return jsNumber(exec, parseFloat(args.at(0).toString(exec))); } AJValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec, AJObject*, AJValue, const ArgList& args) { return jsBoolean(isnan(args.at(0).toNumber(exec))); } AJValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec, AJObject*, AJValue, const ArgList& args) { double n = args.at(0).toNumber(exec); return jsBoolean(!isnan(n) && !isinf(n)); } AJValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec, AJObject*, AJValue, const ArgList& args) { static const char do_not_unescape_when_decoding_URI[] = "#$&+,/:;=?@"; return decode(exec, args, do_not_unescape_when_decoding_URI, true); } AJValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec, AJObject*, AJValue, const ArgList& args) { return decode(exec, args, "", true); } AJValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec, AJObject*, AJValue, const ArgList& args) { static const char do_not_escape_when_encoding_URI[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" "!#$&'()*+,-./:;=?@_~"; return encode(exec, args, do_not_escape_when_encoding_URI); } AJValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec, AJObject*, AJValue, const ArgList& args) { static const char do_not_escape_when_encoding_URI_component[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" "!'()*-._~"; return encode(exec, args, do_not_escape_when_encoding_URI_component); } AJValue JSC_HOST_CALL globalFuncEscape(ExecState* exec, AJObject*, AJValue, const ArgList& args) { static const char do_not_escape[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" "*+-./@_"; AJStringBuilder builder; UString str = args.at(0).toString(exec); const UChar* c = str.data(); for (unsigned k = 0; k < str.size(); k++, c++) { int u = c[0]; if (u > 255) { char tmp[7]; snprintf(tmp, sizeof(tmp), "%%u%04X", u); builder.append(tmp); } else if (u != 0 && strchr(do_not_escape, static_cast<char>(u))) builder.append(c, 1); else { char tmp[4]; snprintf(tmp, sizeof(tmp), "%%%02X", u); builder.append(tmp); } } return builder.build(exec); } AJValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec, AJObject*, AJValue, const ArgList& args) { StringBuilder builder; UString str = args.at(0).toString(exec); int k = 0; int len = str.size(); while (k < len) { const UChar* c = str.data() + k; UChar u; if (c[0] == '%' && k <= len - 6 && c[1] == 'u') { if (isASCIIHexDigit(c[2]) && isASCIIHexDigit(c[3]) && isASCIIHexDigit(c[4]) && isASCIIHexDigit(c[5])) { u = Lexer::convertUnicode(c[2], c[3], c[4], c[5]); c = &u; k += 5; } } else if (c[0] == '%' && k <= len - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) { u = UChar(Lexer::convertHex(c[1], c[2])); c = &u; k += 2; } k++; builder.append(*c); } return jsString(exec, builder.build()); } #ifndef NDEBUG AJValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec, AJObject*, AJValue, const ArgList& args) { CString string = args.at(0).toString(exec).UTF8String(); puts(string.data()); return jsUndefined(); } #endif } // namespace AJ
C++
Apache-2.0
PioneerLab/OpenAphid-AJ/DISCONTINUED/runtime/AJGlobalObjectFunctions.cpp
c461ad0a-0585-4d2b-8cd7-08a02e3c021c
[{"tag": "NAME", "value": "Cameron Zwarich", "start": 786, "end": 801, "context": " Inc. All rights reserved.\n * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)\n * Copyright (C) 2007 M"}, {"tag": "EMAIL", "value": "cwzwarich@uwaterloo.ca", "start": 803, "end": 825, "context": "reserved.\n * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)\n * Copyright (C) 2007 Maks Orlovich\n *\n * This"}, {"tag": "NAME", "value": "Peter Kelly", "start": 645, "end": 656, "context": "ri Porten (porten@kde.org)\n * Copyright (C) 2001 Peter Kelly (pmk@post.com)\n * Copyright (C) 2003, 2004, 2005"}, {"tag": "EMAIL", "value": "porten@kde.org", "start": 606, "end": 620, "context": "\n\n*/\n/*\n * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)\n * Copyright (C) 2001 Peter Kelly (pmk@post.com"}, {"tag": "EMAIL", "value": "pmk@post.com", "start": 658, "end": 670, "context": "rten@kde.org)\n * Copyright (C) 2001 Peter Kelly (pmk@post.com)\n * Copyright (C) 2003, 2004, 2005, 2006, 2007, "}, {"tag": "NAME", "value": "Maks Orlovich", "start": 850, "end": 863, "context": "h (cwzwarich@uwaterloo.ca)\n * Copyright (C) 2007 Maks Orlovich\n *\n * This library is free software; you can red"}, {"tag": "NAME", "value": "Harri Porten", "start": 592, "end": 604, "context": "r the License.\n\n*/\n/*\n * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)\n * Copyright (C) 2001 Peter Kel"}]
[{"tag": "NAME", "value": "Cameron Zwarich", "start": 786, "end": 801, "context": " Inc. All rights reserved.\n * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)\n * Copyright (C) 2007 M"}, {"tag": "EMAIL", "value": "cwzwarich@uwaterloo.ca", "start": 803, "end": 825, "context": "reserved.\n * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)\n * Copyright (C) 2007 Maks Orlovich\n *\n * This"}, {"tag": "NAME", "value": "Peter Kelly", "start": 645, "end": 656, "context": "ri Porten (porten@kde.org)\n * Copyright (C) 2001 Peter Kelly (pmk@post.com)\n * Copyright (C) 2003, 2004, 2005"}, {"tag": "EMAIL", "value": "porten@kde.org", "start": 606, "end": 620, "context": "\n\n*/\n/*\n * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)\n * Copyright (C) 2001 Peter Kelly (pmk@post.com"}, {"tag": "EMAIL", "value": "pmk@post.com", "start": 658, "end": 670, "context": "rten@kde.org)\n * Copyright (C) 2001 Peter Kelly (pmk@post.com)\n * Copyright (C) 2003, 2004, 2005, 2006, 2007, "}, {"tag": "NAME", "value": "Maks Orlovich", "start": 850, "end": 863, "context": "h (cwzwarich@uwaterloo.ca)\n * Copyright (C) 2007 Maks Orlovich\n *\n * This library is free software; you can red"}, {"tag": "NAME", "value": "Harri Porten", "start": 592, "end": 604, "context": "r the License.\n\n*/\n/*\n * Copyright (C) 1999-2002 Harri Porten (porten@kde.org)\n * Copyright (C) 2001 Peter Kel"}]
--- title: Azure SDK for Python (November 2020) layout: post tags: python sidebar: releases_sidebar repository: azure/azure-sdk-for-python --- The Azure SDK team is pleased to make available the November 2020 client library release. #### GA - _Add packages_ #### Updates - _Add packages_ #### Beta - Service Bus - Search - Metrics Advisor - Eventgrid - Form Recognizer ## Installation Instructions To install the latest beta version of the packages, copy and paste the following commands into a terminal: ```bash pip install azure-servicebus --pre pip install azure-search-documents --pre pip install azure-ai-metricsadvisor --pre pip install azure-eventgrid --pre pip install azure-ai-formrecognizer --pre ``` ## Feedback If you have a bug or feature request for one of the libraries, please post an issue to [GitHub](https://github.com/azure/azure-sdk-for-python/issues). ## Release highlights ### Service Bus [Changelog](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/servicebus/azure-servicebus/CHANGELOG.md) #### New Features * Addition of `timeout` paramter to sending, lock renewel, and settlement functions. * Addition of `auto_lock_renewer` parameter when getting a receiver to opt-into auto-registration of lock renewal for messages on receipt (or, if a session receiver, the session on open). #### Breaking changes * Significant renames across parameter, entity, and exception types such as utilizing a ServiceBus prefix, e.g. `ServiceBusMessage`. * Refactors all service-impacting operations from the `ServiceBusMessage` object onto the `ServiceBusReceiver` object itself, e.g. lock renewal and settlement. * `get_*_session_receiver` functions have been incorporated into their `get_*_receiver` counterparts, activated by passing a `session_id` parameter. * Continued Exception behavior cleanup, normalization, and documentation, as well as naming polish in line with the broad name prefix alignment. ### Metrics Advisor [Changelog](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md) #### Breaking Changes - Significant renames across parameters and methods. Please go to the [Changelog](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md) for detail information. ### Form Recognizer [Changelog](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md) This version of the SDK defaults to the latest supported API version, which currently is v2.1-preview. #### New Features - Support for two new prebuilt recognition models for invoices and business cards through the `begin_recognize_invoices()` and `begin_recognize_business_cards()` methods (as well as their `from_url` counterparts) of `FormRecognizerClient`. - Support for selection marks as a new fundamental form element. This type is supported in content recognition and in training/recognizing custom forms (labeled only). - Support for creating composed models from a collection of existing models (trained with labels) through the `begin_create_composed_model()` method of `FormTrainingClient`. - A `model_name` keyword argument added for model training (both `begin_training()` and `begin_create_composed_model()`) that can specify a human-readable name for a model. - Support for the bitmap image format (with content type "image/bmp") in prebuilt model recognition and content recognition. - A `locale` keyword argument added for all prebuilt model methods, allowing for the specification of a document's origin to assist the service with correct analysis of the document's content. - A `language` keyword argument added for the content recognition method `begin_recognize_content()` that specifies which language to process the document in. - A `pages` keyword argument added for the content recognition method `begin_recognize_content()` that specifies which pages in a multi-page document should be analyzed. - Additional properties added to response models - see Changelog for detailed information. ## Latest Releases View all the latest versions of Python packages [here][python-latest-releases]. {% include refs.md %}
Markdown
MIT
DominikMe/azure-sdk/releases/2020-11/python.md
b5f44525-e83c-4631-b0ca-d03ff55b2b4e
[]
[]
/* * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.codemodel.internal.writer; import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import com.sun.codemodel.internal.CodeWriter; import com.sun.codemodel.internal.JPackage; /** * Output all source files into a single stream with a little * formatting header in front of each file. * * This is primarily for human consumption of the generated source * code, such as to debug/test CodeModel or to quickly inspect the result. * * @author * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) */ public class SingleStreamCodeWriter extends CodeWriter { private final PrintStream out; /** * @param os * This stream will be closed at the end of the code generation. */ public SingleStreamCodeWriter( OutputStream os ) { out = new PrintStream(os); } public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { String pkgName = pkg.name(); if(pkgName.length()!=0) pkgName += '.'; out.println( "-----------------------------------" + pkgName+fileName + "-----------------------------------"); return new FilterOutputStream(out) { public void close() { // don't let this stream close } }; } public void close() throws IOException { out.close(); } }
Java
MIT
jsycdut/source-code/openjdk8/openjdk/jaxws/src/share/jaxws_classes/com/sun/codemodel/internal/writer/SingleStreamCodeWriter.java
20ba0cb3-a1d4-4ae6-9dd0-e42eda28e504
[{"tag": "NAME", "value": "Kohsuke Kawaguchi", "start": 1747, "end": 1764, "context": "quickly inspect the result.\n *\n * @author\n * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)\n */\npublic class Sing"}, {"tag": "EMAIL", "value": "kohsuke.kawaguchi@sun.com", "start": 1766, "end": 1791, "context": " result.\n *\n * @author\n * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)\n */\npublic class SingleStreamCodeWriter extends "}]
[{"tag": "NAME", "value": "Kohsuke Kawaguchi", "start": 1747, "end": 1764, "context": "quickly inspect the result.\n *\n * @author\n * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)\n */\npublic class Sing"}, {"tag": "EMAIL", "value": "kohsuke.kawaguchi@sun.com", "start": 1766, "end": 1791, "context": " result.\n *\n * @author\n * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)\n */\npublic class SingleStreamCodeWriter extends "}]
#!/usr/bin/env python # Copyright (c) 2013-2014 Will Thames <will@thames.id.au> # # 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. from __future__ import print_function import errno import optparse import sys import ansiblelint import ansiblelint.formatters as formatters import six from ansiblelint import RulesCollection from ansiblelint.version import __version__ import yaml import os def load_config(config_file): config_path = config_file if config_file else ".ansible-lint" if os.path.exists(config_path): with open(config_path, "r") as stream: try: return yaml.load(stream) except yaml.YAMLError: pass return None def main(): formatter = formatters.Formatter() parser = optparse.OptionParser("%prog [options] playbook.yml [playbook2 ...]", version="%prog " + __version__) parser.add_option('-L', dest='listrules', default=False, action='store_true', help="list all the rules") parser.add_option('-q', dest='quiet', default=False, action='store_true', help="quieter, although not silent output") parser.add_option('-p', dest='parseable', default=False, action='store_true', help="parseable output in the format of pep8") parser.add_option('-r', action='append', dest='rulesdir', default=[], type='str', help="specify one or more rules directories using " "one or more -r arguments. Any -r flags override " "the default rules in %s, unless -R is also used." % ansiblelint.default_rulesdir) parser.add_option('-R', action='store_true', default=False, dest='use_default_rules', help="Use default rules in %s in addition to any extra " "rules directories specified with -r. There is " "no need to specify this if no -r flags are used" % ansiblelint.default_rulesdir) parser.add_option('-t', dest='tags', action='append', default=[], help="only check rules whose id/tags match these values") parser.add_option('-T', dest='listtags', action='store_true', help="list all the tags") parser.add_option('-v', dest='verbosity', action='count', help="Increase verbosity level", default=0) parser.add_option('-x', dest='skip_list', default=[], action='append', help="only check rules whose id/tags do not " + "match these values") parser.add_option('--nocolor', dest='colored', default=hasattr(sys.stdout, 'isatty') and sys.stdout.isatty(), action='store_false', help="disable colored output") parser.add_option('--force-color', dest='colored', action='store_true', help="Try force colored output (relying on ansible's code)") parser.add_option('--exclude', dest='exclude_paths', action='append', help='path to directories or files to skip. This option' ' is repeatable.', default=[]) parser.add_option('-c', help='Specify configuration file to use. Defaults to ".ansible-lint"') options, args = parser.parse_args(sys.argv[1:]) config = load_config(options.c) if config: if 'quiet' in config: options.quiet = options.quiet or config['quiet'] if 'parseable' in config: options.parseable = options.parseable or config['parseable'] if 'use_default_rules' in config: options.use_default_rules = options.use_default_rules or config['use_default_rules'] if 'verbosity' in config: options.verbosity = options.verbosity + config['verbosity'] if 'exclude_paths' in config: options.exclude_paths = options.exclude_paths + config['exclude_paths'] if 'rulesdir' in config: options.rulesdir = options.rulesdir + config['rulesdir'] if 'skip_list' in config: options.skip_list = options.skip_list + config['skip_list'] if 'tags' in config: options.tags = options.tags + config['tags'] if options.quiet: formatter = formatters.QuietFormatter() if options.parseable: formatter = formatters.ParseableFormatter() if len(args) == 0 and not (options.listrules or options.listtags): parser.print_help(file=sys.stderr) return 1 if options.use_default_rules: rulesdirs = options.rulesdir + [ansiblelint.default_rulesdir] else: rulesdirs = options.rulesdir or [ansiblelint.default_rulesdir] rules = RulesCollection() for rulesdir in rulesdirs: rules.extend(RulesCollection.create_from_directory(rulesdir)) if options.listrules: print(rules) return 0 if options.listtags: print(rules.listtags()) return 0 if isinstance(options.tags, six.string_types): options.tags = options.tags.split(',') skip = set() for s in options.skip_list: skip.update(s.split(',')) options.skip_list = frozenset(skip) playbooks = set(args) matches = list() checked_files = set() for playbook in playbooks: runner = ansiblelint.Runner(rules, playbook, options.tags, options.skip_list, options.exclude_paths, options.verbosity, checked_files) matches.extend(runner.run()) matches.sort(key=lambda x: (x.filename, x.linenumber, x.rule.id)) for match in matches: print(formatter.format(match, options.colored)) if len(matches): return 2 else: return 0 if __name__ == "__main__": try: sys.exit(main()) except IOError as exc: if exc.errno != errno.EPIPE: raise except RuntimeError as e: raise SystemExit(str(e))
Python
MIT
Chrislyle8/Test/lib/ansiblelint/__main__.py
857a888e-5f69-442b-ae26-a7df7909ebc2
[{"tag": "EMAIL", "value": "will@thames.id.au", "start": 62, "end": 79, "context": "nv python\n\n# Copyright (c) 2013-2014 Will Thames <will@thames.id.au>\n#\n# Permission is hereby granted, free of charge"}, {"tag": "NAME", "value": "Will Thames", "start": 49, "end": 60, "context": "#!/usr/bin/env python\n\n# Copyright (c) 2013-2014 Will Thames <will@thames.id.au>\n#\n# Permission is hereby gran"}]
[{"tag": "EMAIL", "value": "will@thames.id.au", "start": 62, "end": 79, "context": "nv python\n\n# Copyright (c) 2013-2014 Will Thames <will@thames.id.au>\n#\n# Permission is hereby granted, free of charge"}, {"tag": "NAME", "value": "Will Thames", "start": 49, "end": 60, "context": "#!/usr/bin/env python\n\n# Copyright (c) 2013-2014 Will Thames <will@thames.id.au>\n#\n# Permission is hereby gran"}]
/** * @author {benyuwan@gmail.com} * @file tags的model */ import query from '../utils/query' import escape from '../utils/escape' class Tags { async updateTag(id, tags) { return await query(escape`UPDATE ARTICLE SET tags=${tags} WHERE id=${id}`) } } export default new Tags()
JavaScript
MIT
StudentWan/ashen-blog/server/models/tags.js
0e759623-bbc5-46ec-a592-3243cba2fc25
[{"tag": "EMAIL", "value": "benyuwan@gmail.com", "start": 16, "end": 34, "context": "/**\n * @author {benyuwan@gmail.com}\n * @file tags\u7684model\n */\n\nimport query from '../u"}]
[{"tag": "EMAIL", "value": "benyuwan@gmail.com", "start": 16, "end": 34, "context": "/**\n * @author {benyuwan@gmail.com}\n * @file tags\u7684model\n */\n\nimport query from '../u"}]
# -*- coding: utf-8 -*- # vim: ts=2 sw=2 et ai ############################################################################### # Copyright (c) 2012,2013-2021 Andreas Vogel andreas@wellenvogel.net # # 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. # # parts from this software (AIS decoding) are taken from the gpsd project # so refer to this BSD licencse also (see ais.py) or omit ais.py # parts contributed by free-x https://github.com/free-x # parts contributed by Matt Hawkins http://www.raspberrypi-spy.co.uk/ # ############################################################################### import hashlib import avnav_handlerList from avnav_nmea import * from avnav_worker import * class AVNUserAppHandler(AVNWorker): ''' handle the files in the user directory ''' CHILDNAME="UserTool" TYPE="addon" @classmethod def getStartupGroup(cls): return 3 @classmethod def getPrefix(cls): return None @classmethod def getConfigParam(cls, child=None): #we add this to the ones configured at HTTPServer if child == cls.CHILDNAME: return { 'url':None, #we replace $HOST... 'title':'', 'icon':None, #an icon below $datadir/user 'keepUrl':'' #auto detect } if not child is None: return None rt = { 'interval': '5', } return rt @classmethod def preventMultiInstance(cls): return True @classmethod def autoInstantiate(cls): return True def __init__(self,param): self.userHandler=None # AVNUserHandler self.imagesHandler=None # AVNImagesHandler self.httpServer=None # AVNHTTPServer self.addonList=[] self.additionalAddOns=[] AVNWorker.__init__(self,param) def startInstance(self, navdata): self.userHandler=self.findHandlerByName('AVNUserHandler') if self.userHandler is None: raise Exception("unable to find a user handler") self.imagesHandler=self.findHandlerByName('AVNImagesHandler') if self.imagesHandler is None: raise Exception("unable to find an images handler") self.httpServer = self.findHandlerByName('AVNHttpServer') if self.httpServer is None: raise Exception("unable to find AVNHttpServer") super().startInstance(navdata) # thread run method - just try forever def run(self): sleepTime=self.getFloatParam('interval') self.setInfo('main', "starting", WorkerStatus.STARTED) self.fillList() while not self.shouldStop(): self.wait(sleepTime) def computeKey(self,entry): md5=hashlib.md5() for k in ('url','icon','title'): v=entry.get(k) if v is not None: try: md5.update(v.encode('utf-8')) except Exception as e: AVNLog.error("unable to compute md5 for %s: %s",v,e) return md5.hexdigest() def fillList(self): data = [] alreadyFound=set() childlist = self.param.get(self.CHILDNAME) if childlist is not None: for child in childlist: url=child.get('url') key=self.computeKey(child) if url is None: child['invalid']=True if key in alreadyFound: AVNLog.error("duplicate user app found, ignoring %s",url) while key in alreadyFound: key = key + "x" child['name']=key child['invalid']=True else: child['name']=key alreadyFound.add(key) item=child.copy() item['canDelete']=True item['source']='user' data.append(item) serverAddons = self.httpServer.getParamValue(self.CHILDNAME) nr=0 if serverAddons is not None: for addon in serverAddons: newAddon = addon.copy() newAddon['canDelete']=False newAddon['name']="server:%d"%nr newAddon['source']='legacy' nr+=1 data.append(newAddon) for addon in data: url = addon.get('url') if url is None: addon['invalid']=True if not url.startswith("http"): userFile = self.findFileForUrl(url) if userFile is None: AVNLog.error("error: user url %s not found", url) addon['invalid']=True if addon.get('title') == '': del addon['title'] keepUrl = False if addon.get('keepUrl') is None or addon.get('keepUrl') == '': if addon.get('url').startswith("http"): keepUrl = True else: if str(addon.get('keepUrl')).lower() == "true": keepUrl = True addon['keepUrl'] = keepUrl icon = addon['icon'] if not icon.startswith("http"): if not icon.startswith("/user"): icon="/user/"+icon addon['icon']=icon iconpath = self.findFileForUrl(icon) if iconpath is None: AVNLog.error("icon path %s for %s not found, ignoring entry", icon, addon['url']) addon['invalid'] = True self.addonList=data self.setInfo('main', "active, %d addons"%len(data), WorkerStatus.NMEA) return def findFileForUrl(self,url): if url is None: return None if url.startswith("http"): return None (path,query)=self.httpServer.pathQueryFromUrl(url) filePath=self.httpServer.tryExternalMappings(path,query) if filePath is None or not os.path.exists(filePath): return None return filePath def findChild(self,name,ignoreInvalid=False): children=self.param.get(self.CHILDNAME) if children is None: return -1 if not isinstance(children,list): return -1 for i in range(0,len(children)): child =children[i] if child.get('name') == name: if ignoreInvalid: inList=[e for e in self.addonList if e.get('name') == name and not ( e.get('invalid') == True)] if len(inList) < 0: return -1 return i return -1 def getChildConfig(self,name): idx=self.findChild(name) if idx < 0: return {} else: return self.param[self.CHILDNAME][idx] def handleDelete(self,name): if name is None: raise Exception("missing name") name = AVNUtil.clean_filename(name) idx=self.findChild(name) if idx < 0: raise Exception("unable to find %s"%name) self.removeChildConfig(self.CHILDNAME,idx) self.fillList() def handleList(self,httpHandler,includeInvalid): host = httpHandler.headers.get('host') hostparts = host.split(':') outdata=[] src=self.additionalAddOns+self.addonList for addon in src: if addon.get('invalid') == True and not includeInvalid: continue item=addon.copy() if hostparts is not None: item['originalUrl']=addon['url'] item['url'] = addon['url'].replace('$HOST', hostparts[0]) outdata.append(item) rt = AVNUtil.getReturnData(items=outdata) return rt def getHandledCommands(self): rt={"api": self.TYPE, "list": self.TYPE, "delete": self.TYPE} prefix=self.getPrefix() if prefix is not None: rt["path"]=prefix return rt def checkName(self,name,doRaise=True): cleanName=AVNUtil.clean_filename(name) if name != cleanName: if doRaise: raise Exception("name %s is invalid"%name) return False return True def registerAddOn(self,name,url,iconPath,title=None): newAddon = { 'name': name, 'url': url, 'icon': iconPath, 'title': title, 'canDelete': False, 'source':'plugin' } self.additionalAddOns.append(newAddon) def unregisterAddOn(self,name): if name is None: raise Exception("name cannot be None") for ao in self.additionalAddOns: if ao.get('name') == name: self.additionalAddOns.remove(ao) return True def deleteByUrl(self,url): """ called by the user handler when a user file is deleted @param url: @return: """ if url is None: return for addon in self.addonList: if addon.get('canDelete') == True and addon.get('url') == url: self.handleDelete(addon.get('name')) def handleApiRequest(self, type, subtype, requestparam, **kwargs): if type == 'api': command=AVNUtil.getHttpRequestParam(requestparam,'command',True) name=AVNUtil.getHttpRequestParam(requestparam,'name',False) if command == 'delete': self.handleDelete(name) return AVNUtil.getReturnData() elif command == 'list': includeInvalid = AVNUtil.getHttpRequestParam(requestparam, "invalid") return self.handleList(kwargs.get('handler'),includeInvalid is not None and includeInvalid.lower() == 'true') elif command == 'update': url=AVNUtil.getHttpRequestParam(requestparam,'url',True) icon=AVNUtil.getHttpRequestParam(requestparam,'icon',True) title=AVNUtil.getHttpRequestParam(requestparam,'title') param = {} param['icon'] = icon param['title'] = title param['url'] = url param['keepUrl'] = url.startswith("http") doAdd=False if name is None: doAdd=True name=self.computeKey(param) #add for entry in self.addonList: if entry['name'] == name: raise Exception("trying to add an already existing url %s"%url) param['name']=name if not url.startswith("http"): userFile=self.findFileForUrl(url) if userFile is None: raise Exception("unable to find a local file for %s"%url) if not icon.startswith("http"): iconFile=self.findFileForUrl(icon) if iconFile is None: raise Exception("unable to find an icon file for %s"%icon) idx=self.findChild(name) if idx < 0 and not doAdd: raise Exception("did not find a user app with this name") for k in list(param.keys()): idx=self.changeChildConfig(self.CHILDNAME,idx,k,param[k],True) self.writeConfigChanges() self.fillList() return AVNUtil.getReturnData() raise Exception("unknown command for %s api request: %s"%(self.type,command)) if type == "list": includeInvalid=AVNUtil.getHttpRequestParam(requestparam,"invalid") return self.handleList(kwargs.get('handler'),includeInvalid is not None and includeInvalid.lower() == 'true') if type == 'delete': name = AVNUtil.getHttpRequestParam(requestparam, "name",True) self.handleDelete(name) return AVNUtil.getReturnData() raise Exception("unable to handle user request %s"%(type)) avnav_handlerList.registerHandler(AVNUserAppHandler)
Python
MIT
Littlechay/avnav/server/handler/avnuserapps.py
6a6d190a-071d-496d-8be3-9665b7913424
[{"tag": "EMAIL", "value": "andreas@wellenvogel.net", "start": 172, "end": 195, "context": "####\n# Copyright (c) 2012,2013-2021 Andreas Vogel andreas@wellenvogel.net\n#\n# Permission is hereby granted, free of charge"}, {"tag": "NAME", "value": "Matt Hawkins", "start": 1492, "end": 1504, "context": "https://github.com/free-x\n# parts contributed by Matt Hawkins http://www.raspberrypi-spy.co.uk/\n#\n#############"}, {"tag": "NAME", "value": "Andreas Vogel", "start": 158, "end": 171, "context": "##################\n# Copyright (c) 2012,2013-2021 Andreas Vogel andreas@wellenvogel.net\n#\n# Permission is hereby"}]
[{"tag": "EMAIL", "value": "andreas@wellenvogel.net", "start": 172, "end": 195, "context": "####\n# Copyright (c) 2012,2013-2021 Andreas Vogel andreas@wellenvogel.net\n#\n# Permission is hereby granted, free of charge"}, {"tag": "NAME", "value": "Matt Hawkins", "start": 1492, "end": 1504, "context": "https://github.com/free-x\n# parts contributed by Matt Hawkins http://www.raspberrypi-spy.co.uk/\n#\n#############"}, {"tag": "NAME", "value": "Andreas Vogel", "start": 158, "end": 171, "context": "##################\n# Copyright (c) 2012,2013-2021 Andreas Vogel andreas@wellenvogel.net\n#\n# Permission is hereby"}]
require File.dirname(__FILE__) + '/../../spec_helper' # include Remote class TestEC2Class include PoolParty::Remote::RemoterBase include Ec2 include CloudResourcer include CloudDsl def keypair "fake_keypair" end def ami;"ami-abc123";end def size; "small";end def security_group; "default";end def ebs_volume_id; "ebs_volume_id";end def availabilty_zone; "us-east-1a";end def verbose false end def ec2 @ec2 ||= EC2::Base.new( :access_key_id => "not_an_access_key", :secret_access_key => "not_a_secret_access_key") end end describe "ec2 remote base" do before(:each) do setup @tr = TestEC2Class.new stub_remoter_for(@tr) @tr.stub!(:get_instances_description).and_return response_list_of_instances end %w(launch_new_instance! terminate_instance! describe_instance describe_instances create_snapshot).each do |method| eval <<-EOE it "should have the method #{method}" do @tr.respond_to?(:#{method}).should == true end EOE end describe "helpers" do it "should be able to convert an ec2 ip to a real ip" do "ec2-72-44-36-12.compute-1.amazonaws.com".convert_from_ec2_to_ip.should == "72.44.36.12" end it "should not throw an error if another string is returned" do "72.44.36.12".convert_from_ec2_to_ip.should == "72.44.36.12" end it "should be able to parse the date from the timestamp" do "2008-11-13T09:33:09+0000".parse_datetime.should == DateTime.parse("2008-11-13T09:33:09+0000") end it "should rescue itself and just return the string if it fails" do "thisisthedate".parse_datetime.should == "thisisthedate" end end describe "launching" do before(:each) do @tr.ec2.stub!(:run_instances).and_return true end it "should call run_instances on the ec2 Base class when asking to launch_new_instance!" do @tr.ec2.should_receive(:run_instances).and_return true @tr.launch_new_instance! end it "should use a specific security group if one is specified" do @tr.stub!(:security_group).and_return "web" @tr.ec2.should_receive(:run_instances).with(hash_including(:group_id => ['web'])).and_return true @tr.launch_new_instance! end it "should use the default security group if none is specified" do @tr.ec2.should_receive(:run_instances).with(hash_including(:group_id => ['default'])).and_return true @tr.launch_new_instance! end it "should get the hash response from EC2ResponseObject" do EC2ResponseObject.should_receive(:get_hash_from_response).and_return true @tr.launch_new_instance! end end describe "terminating" do it "should call terminate_instance! on ec2 when asking to terminate_instance!" do @tr.ec2.should_receive(:terminate_instances).with(:instance_id => "abc-123").and_return true @tr.terminate_instance!("abc-123") end end describe "describe_instance" do it "should call get_instances_description on itself" do @tr.should_receive(:get_instances_description).and_return {} @tr.describe_instance end end describe "get_instances_description" do it "should return a hash" do @tr.describe_instances.class.should == Array end it "should call the first node master" do @tr.describe_instances.first[:name].should == "master" end it "should call the second one node1" do @tr.describe_instances[1][:name].should == "node1" end it "should call the third node2" do @tr.describe_instances[2][:name].should == "terminated_node2" end end describe "create_keypair" do before(:each) do Kernel.stub!(:system).with("ec2-add-keypair fake_keypair > #{Base.base_keypair_path}/id_rsa-fake_keypair && chmod 600 #{Base.base_keypair_path}/id_rsa-fake_keypair").and_return true end it "should send system to the Kernel" do Kernel.should_receive(:system).with("ec2-add-keypair fake_keypair > #{Base.base_keypair_path}/id_rsa-fake_keypair && chmod 600 #{Base.base_keypair_path}/id_rsa-fake_keypair").and_return true @tr.create_keypair end it "should try to create the directory when making a new keypair" do FileUtils.should_receive(:mkdir_p).and_return true ::File.stub!(:directory?).and_return false @tr.create_keypair end it "should not create a keypair if the keypair is nil" do Kernel.should_not_receive(:system) @tr.stub!(:keypair).and_return nil @tr.create_keypair end end describe "create_snapshot" do # We can assume that create_snapshot on the ec2 gem works before(:each) do @tr.ec2.stub!(:create_snapshot).and_return nil end it "should create a snapshot of the current EBS volume" do @tr.ec2.stub!(:create_snapshot).and_return {{"snapshotId" => "snap-123"}} @tr.stub!(:ebs_volume_id).and_return "vol-123" @tr.create_snapshot.should == {"snapshotId" => "snap-123"} end it "should not create a snapshot if there is no EBS volume" do @tr.create_snapshot.should == nil end end end
Ruby
MIT
joerichsen/poolparty/spec/poolparty/net/remote_bases/ec2_spec.rb
9ed27b97-d674-4161-9aa4-1af798a52090
[{"tag": "IP_ADDRESS", "value": "72.44.36.12", "start": 1336, "end": 1347, "context": " \"72.44.36.12\".convert_from_ec2_to_ip.should == \"72.44.36.12\"\n end\n it \"should be able to parse the date"}, {"tag": "IP_ADDRESS", "value": "72.44.36.12", "start": 1289, "end": 1300, "context": "an error if another string is returned\" do\n \"72.44.36.12\".convert_from_ec2_to_ip.should == \"72.44.36.12\"\n "}]
[{"tag": "IP_ADDRESS", "value": "72.44.36.12", "start": 1336, "end": 1347, "context": " \"72.44.36.12\".convert_from_ec2_to_ip.should == \"72.44.36.12\"\n end\n it \"should be able to parse the date"}, {"tag": "IP_ADDRESS", "value": "72.44.36.12", "start": 1289, "end": 1300, "context": "an error if another string is returned\" do\n \"72.44.36.12\".convert_from_ec2_to_ip.should == \"72.44.36.12\"\n "}]
import type { CustomNextPage } from "next"; import { useState } from "react"; import { useForm } from "react-hook-form"; import { useManageAccount } from "src/hook/vendor/useManageAccount"; import { Layout } from "src/layout"; import { Attention, InputLayout, InputType, } from "src/pages/vendor/auth/component"; import type { TypeEmail, TypeRadio, TypeSelect, TypeTel, TypeText, TypeTextarea, TypeUrl, } from "src/type/vendor"; import type Stripe from "stripe"; const inputItems: ( | TypeEmail | TypeRadio | TypeSelect | TypeTel | TypeText | TypeUrl | TypeTextarea )[] = [ // { // id: "business_type", // label: "事業形態", // type: "radio", // radioItem: [{ id: "individual" }, { id: "company" }, { id: "non_profit" }], // }, // { // id: "first_name_kanji", // label: "氏名", // type: "text", // placeholder: "姓", // }, // { // id: "last_name_kanji", // label: "氏名", // type: "text", // placeholder: "名", // }, // { // id: "first_name_kana", // label: "氏名(かな)", // type: "text", // placeholder: "姓", // }, // { // id: "last_name_kana", // label: "氏名(かな)", // type: "text", // placeholder: "名", // }, { id: "email", label: "メールアドレス", type: "email", autoComplete: "email", placeholder: "test.satou@example.com", }, // { // id: "businessProfileMcc", // label: "事業カテゴリー", // type: "select", // selectItem: [ // { value: "", text: "選んでください。" }, // { value: "Dog", text: "Dog" }, // { value: "Cat", text: "Cat" }, // { value: "Bird", text: "Bird" }, // ], // }, // { // id: "businessProfileProductDescription", // label: "事業詳細", // type: "textarea", // }, ]; const Create: CustomNextPage = () => { const [isLoading, setIsLoading] = useState(false); const { createAccount, createAccountLink } = useManageAccount(); const { register, handleSubmit, formState: { errors }, } = useForm(); const onSubmit = async (e: any) => { setIsLoading(true); const params: Stripe.AccountCreateParams = { ...e }; const { id } = await createAccount(params); await createAccountLink(id); setIsLoading(false); }; return ( <div className="mx-auto max-w-[700px] text-center"> <div className="space-y-3"> <h2>チケットオーナーアカウント作成</h2> <Attention /> <div className="p-10 rounded-lg border border-gray"> <form onSubmit={handleSubmit(onSubmit)} className="text-center"> {inputItems.map((item) => { return ( <InputLayout key={item.id} item={item} errorMessage={errors}> <InputType item={item} register={register} /> </InputLayout> ); })} <div className="relative py-2 px-5"> <input type="submit" value="送信" /> {isLoading && ( <div className="flex absolute inset-0 justify-center bg-white"> <div className="w-5 h-5 rounded-full border-4 border-blue border-t-transparent animate-spin"></div> </div> )} </div> </form> </div> </div> </div> ); }; Create.getLayout = Layout; export default Create;
TypeScript
MIT
yu-Yoshiaki/Ticketia/src/pages/vendor/auth/create.page.tsx
2cc29e0f-e1f0-47ac-af0d-0d5587e1f1cb
[{"tag": "EMAIL", "value": "test.satou@example.com", "start": 1338, "end": 1360, "context": "il\",\n autoComplete: \"email\",\n placeholder: \"test.satou@example.com\",\n },\n // {\n // id: \"businessProfileMcc\",\n "}]
[{"tag": "EMAIL", "value": "test.satou@example.com", "start": 1338, "end": 1360, "context": "il\",\n autoComplete: \"email\",\n placeholder: \"test.satou@example.com\",\n },\n // {\n // id: \"businessProfileMcc\",\n "}]
export * from 'https://deno.land/std@0.142.0/testing/asserts.ts';
TypeScript
MIT
Azulamb/minirachne/tests/_setup.ts
08b21444-41cd-466e-bc66-a391f37b1bb1
[]
[]
End of preview. Expand in Data Studio

Dataset Card for "dummy_data_clean"

More Information needed

Downloads last month
28